极光推送的封装问题

Discussion in 'Chinese Forum' started by bjfhs, Mar 20, 2017.

  1. bjfhs

    bjfhs Member Licensed User

    我用b4i想开发一个小程序,因为不想自己搭建服务器,想封装第三方的推送,所以用到了第三方推送,想使用第三方sdk,却不会封装,因为不会object-c,哪位大神帮帮忙?极光相关资料https://www.jiguang.cn/push
     
  2. bjfhs

    bjfhs Member Licensed User

    另外,我试着用AdditionalLib,怎么总是报错(我已经把对应的.a.h文件拷贝到mac对应的libs文件夹)
    ld: framework not found jpush-ios-3.0.2
    clang: error: linker command failed with exit code 1
     
  3. kk.cn

    kk.cn New Member

    Hi, bjfhs
    可以请教您是如何封装极光推送sdk的吗?
    我使用B4A ,为了第三方的sdk问了好多QQ群都只说了要封装.....
    实际上都没有详细的封装方法.
    谢谢.
     
  4. bjfhs

    bjfhs Member Licensed User

    B4A 的话只要稍微懂一点java只是,在记事本中输入相应代码,然后用SimpleLibraryCompiler封装即可,下面是我简单的封装方法,因为Java我掌握的也不是太好,所以代码可能不是最优,但可以正常调用了。
    Code:
    package com.myPush;

    import cn.jpush.android.api.JPushInterface;
    import cn.jpush.android.api.TagAliasCallback;

    import java.util.Set;
    import java.util.HashSet;
    import anywheresoftware.b4a.BA.Events;
    import anywheresoftware.b4a.BA;
    import anywheresoftware.b4a.BA.ActivityObject;
    import anywheresoftware.b4a.BA.DependsOn;
    import anywheresoftware.b4a.BA.Permissions;
    import anywheresoftware.b4a.BA.ShortName;
    import anywheresoftware.b4a.BA.Version;

    @Version(
    1.0f)
    @Permissions(values={
    "android.permission.INTERNET"})
    @ShortName("myJpush")
    //@DependsOn(values={"myPush"})
    @Events(values={"mycallback(code As int)"})
    @ActivityObject
    public class myPushWrapper {
         private String eventName;
         private BA ba; 
          public void setDebugMode(boolean v){
               JPushInterface.setDebugMode(v);
           };
           
        public void init(BA ba, String EventName) {
             this.ba = ba;
                  this.eventName = EventName.toLowerCase(ba.cul);
                 JPushInterface.init(ba.context);
        }



        public void setAlias(BA ba,String nam) {
            this.ba = ba;
                JPushInterface.setAlias(ba.context,nam,mAliasCallback);
        }
       
           

         private final TagAliasCallback mAliasCallback = new TagAliasCallback() {
           @Override
           public void gotResult(int code, String alias, Set<String> tags) {
              ba.Log( eventName + "_myCallback");
            // ba.raiseEvent(this, eventName + "_myCallback", code);
               ba.raiseEventFromDifferentThread(this, null, 0,eventName + "_mycallback" , false, new Object[] {code});
           }
         };
         
    }
     
  5. kk.cn

    kk.cn New Member

    谢谢您的回复,
    以极光推送sdk为例,下载后的sdk只有 .jar 及 .so文件, 但是SLC封装除了.jar之外还要.java 文件
    这部分您是如何克服的呢?

    谢谢
     
  6. Gfriends

    Gfriends New Member

    SLC封装似乎只能用.jar及.java文件
    极光推送SDK下载后只有.jar 及.so, 楼主可以指导一下如何封装的吗? 谢谢
     
  7. bjfhs

    bjfhs Member Licensed User

    您好!我第一次回复的就是JAVA代码啊!用记事本编辑好即可,,将.jar和.so放到对应文件夹下,然后用SimpleLibraryCompiler封装
     
  8. Gfriends

    Gfriends New Member

    明白了, .JAVA文件自己编辑, 搭配.JAR就可以封装了
    然后.SO不用理会是吧?
     
  9. bjfhs

    bjfhs Member Licensed User

    .so也应该一起打包进去的吧。放在libs目录下。
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice