IOS 极光推送一直获取不到registrationID 也不知道错误出在哪里


#1

IOS 极光推送一直获取不到registrationID 也不知道错误出在哪里
android版本正常可以
IOS的不行
我使用的是 jpush-phonegap-plugin 3.2.12 通过cordova 命令行安装的
我使用的是里面提供的demo
控制台输出如下,没有返回错误,无法排查问题

2017-12-15 10:38:56.145561+0800 hongbao111[3167:1389265] Finished load of: file:///var/containers/Bundle/Application/809DAFBE-019E-4CD2-B622-14D3CA5EA816/hongbao111.app/www/example/index.html
2017-12-15 10:38:56.245333+0800 hongbao111[3167:1389265] ### pluginInitialize
2017-12-15 10:38:56.250967+0800 hongbao111[3167:1389320]  | JIGUANG | D - [JIGUANGService] Action - setDebugMode
2017-12-15 10:38:56.258652+0800 hongbao111[3167:1389265] THREAD WARNING: ['JPushPlugin'] took '13.060059' ms. Plugin should use a background thread.
2017-12-15 10:38:57.254188+0800 hongbao111[3167:1389320]  | JIGUANG | D - [JIGUANGService] Action - registrationID
2017-12-15 10:38:57.257003+0800 hongbao111[3167:1389265] 获取id
2017-12-15 10:38:57.268279+0800 hongbao111[3167:1389265] JPushPlugin:registrationID is
2017-12-15 10:38:58.265998+0800 hongbao111[3167:1389320]  | JIGUANG | D - [JIGUANGService] Action - registrationID
2017-12-15 10:38:58.267520+0800 hongbao111[3167:1389265] 获取id
2017-12-15 10:38:58.276918+0800 hongbao111[3167:1389265] JPushPlugin:registrationID is
2017-12-15 10:38:59.281434+0800 hongbao111[3167:1389320]  | JIGUANG | D - [JIGUANGService]

#2

开启 debug 看完整的日志,是否集成有问题。


#3

你说的是这个吗?我已经打开了啊,官方的 demo

        var initiateUI = function() {
          try {
            window.JPush.init();
            window.JPush.setDebugMode(true);
            window.setTimeout(getRegistrationID, 1000);

            if (device.platform != "Android") {
              window.JPush.setApplicationIconBadgeNumber(0);
            }
          } catch (exception) {
            console.log(exception);
          }

#4

IOS我不太懂哈,大神你说的是极光的日志还是IOS的日志


#5

极光js里的日志有打开的,用的是默认提供的代码,我都没改动
window.JPush.init();
window.JPush.setDebugMode(true);
window.setTimeout(getRegistrationID, 1000);


#6

极光的日志,你给的不全,从初始化开始的日志信息。


#7

从开始的日志

2017-12-15 11:48:43.776121+0800 hongbao111[3192:1407041] Apache Cordova native platform version 4.3.1 is starting.
2017-12-15 11:48:43.777250+0800 hongbao111[3192:1407041] Multi-tasking -> Device: YES, App: YES
2017-12-15 11:48:43.993059+0800 hongbao111[3192:1407041] [MC] Loaded MobileCoreServices.framework
2017-12-15 11:48:44.009833+0800 hongbao111[3192:1407041] Using UIWebView
2017-12-15 11:48:44.012911+0800 hongbao111[3192:1407041] [CDVTimer][handleopenurl] 0.184000ms
2017-12-15 11:48:44.017552+0800 hongbao111[3192:1407041] [CDVTimer][intentandnavigationfilter] 4.427016ms
2017-12-15 11:48:44.017996+0800 hongbao111[3192:1407041] [CDVTimer][gesturehandler] 0.240982ms
2017-12-15 11:48:44.018417+0800 hongbao111[3192:1407041] [CDVTimer][alipay] 0.226021ms
2017-12-15 11:48:44.082757+0800 hongbao111[3192:1407041] [CDVTimer][splashscreen] 64.242005ms
2017-12-15 11:48:44.083048+0800 hongbao111[3192:1407041] [CDVTimer][clipboard] 0.134051ms
2017-12-15 11:48:44.083102+0800 hongbao111[3192:1407041] [CDVTimer][TotalPluginStartup] 70.465028ms
2017-12-15 11:48:44.314841+0800 hongbao111[3192:1407041] refreshPreferences: HangTracerEnabled: 0
2017-12-15 11:48:44.314966+0800 hongbao111[3192:1407041] refreshPreferences: HangTracerDuration: 500
2017-12-15 11:48:44.315032+0800 hongbao111[3192:1407041] refreshPreferences: ActivationLoggingEnabled: 0 ActivationLoggingTaskedOffByDA:0
2017-12-15 11:48:44.505090+0800 hongbao111[3192:1407041] Resetting plugins due to page load.
2017-12-15 11:48:45.141346+0800 hongbao111[3192:1407121] NSURLConnection finished with error - code -1100
2017-12-15 11:48:45.165691+0800 hongbao111[3192:1407041] Finished load of: file:///var/containers/Bundle/Application/C1AF9689-779A-4E9B-A010-E92FD8E12DEC/hongbao111.app/www/example/index.html
2017-12-15 11:48:45.244021+0800 hongbao111[3192:1407041] ### pluginInitialize
2017-12-15 11:48:45.253338+0800 hongbao111[3192:1407104]  | JIGUANG | D - [JIGUANGService] Action - setDebugMode
2017-12-15 11:48:46.256323+0800 hongbao111[3192:1407105]  | JIGUANG | D - [JIGUANGService] Action - registrationID
2017-12-15 11:48:46.258250+0800 hongbao111[3192:1407041] 获取id
2017-12-15 11:48:46.275423+0800 hongbao111[3192:1407041] JPushPlugin:registrationID is
2017-12-15 11:48:47.274556+0800 hongbao111[3192:1407121]  | JIGUANG | D - [JIGUANGService] Action - registrationID
2017-12-15 11:48:47.276146+0800 hongbao111[3192:1407041] 获取id
2017-12-15 11:48:47.284385+0800 hongbao111[3192:1407041] JPushPlugin:registrationID is
2017-12-15 11:48:48.290180+0800 hongbao111[3192:1407121]  | JIGUANG | D - [JIGUANGService]

#8

额, 你有调初始化代码吗?有配AppKey吗
https://docs.jiguang.cn/jpush/client/iOS/ios_guide_new/#_6


#9

我用的是cordova插件,应该不用我写代码到这里吧,貌似是cordova来调用的,安装插件的步骤里是不需要再自己写的,插件里都应该是写好了的


#10

不知道这个配置有没有生效,都是自动安装的,IOS我实在是一窍不通,麻烦你了


#11

jpush-phonegap-plugin 插件文档描述
本插件默认在 App 启动完成之后,立即「注册苹果通知服务」+「启动 JPush SDK」,其中:

「注册苹果通知服务」会弹出提示窗口向用户请求权限。
「启动 JPush SDK」是使用 JPush 各项 API 的必要条件。

我没有收到权限申请的通知,应该是没有启动成功,我又不知道该怎么处理了


(HuminiOS) #12

getRegistrationID 的调用代码发我看看。


#13

cordova 插件是js调用的

    var onDeviceReady = function() {
      document.addEventListener("jpush.receiveRegistrationId", function (event) {
            alert("receiveRegistrationId" + JSON.stringify(event));
            $("#registrationId").html(event.registrationId);
        }, false)

      initiateUI();
    };
  
    var getRegistrationID = function() {
      var a = window.JPush.getRegistrationID(onGetRegistrationID);
      console.log('获取id',a);
    };
  
    var onGetRegistrationID = function(data) {
      try {
        console.log("JPushPlugin:registrationID is " + data);
        
        if (data.length == 0) {
          var t1 = window.setTimeout(getRegistrationID, 1000);
        }

        $("#registrationId").html(data);
      } catch (exception) {
        console.log(exception);
      }
    };
  
    var onTagsWithAlias = function(event) {
      try {
        console.log("onTagsWithAlias");
        var result = "result code:" + event.resultCode + " ";
        result += "tags:" + event.tags + " ";
        result += "alias:" + event.alias + " ";
        $("#tagAliasResult").html(result);
      } catch (exception) {
        console.log(exception)
      }
    };
  
    var onOpenNotification = function(event) {
      try {
        var alertContent;
        if (device.platform == "Android") {
          alertContent = event.alert;
        } else {
          alertContent = event.aps.alert;
        }
        alert("open Notification:" + alertContent);
      } catch (exception) {
        console.log("JPushPlugin:onOpenNotification" + exception);
      }
    };
    
    var onReceiveNotification = function(event) {
      try {
        var alertContent;
        if (device.platform == "Android") {
          alertContent = event.alert;
        } else {
          alertContent = event.aps.alert;
        }
        $("#notificationResult").html(alertContent);
      } catch (exception) {
        console.log(exception)
      }
    };
  
    var onReceiveMessage = function(event) {
      try {
        var message;
        if (device.platform == "Android") {
          message = event.message;
        } else {
          message = event.content;
        }
        $("#messageResult").html(message);
      } catch (exception) {
        console.log("JPushPlugin:onReceiveMessage-->" + exception);
      }
    };
  
    var initiateUI = function() {
      try {
        window.JPush.init();
        window.JPush.setDebugMode(true);
        window.setTimeout(getRegistrationID, 1000);

        if (device.platform != "Android") {
          window.JPush.setApplicationIconBadgeNumber(0);
        }
      } catch (exception) {
        console.log(exception);
      }

      $("#setTags").click(function(ev) {
        try {
          var tag1 = $("#tagText1").val()
          var tag2 = $("#tagText2").val()
          var tag3 = $("#tagText3").val()
          var tags = []
                                        
          if (tag1) {
            tags.push(tag1)
          }
          if (tag2) {
            tags.push(tag2)
          }
          if (tag3) {
            tags.push(tag3)
          }

          window.JPush.setTags({ sequence: 1, tags: tags },
            function (result) {
              $("#tagsResult").html(result.tags)
            }, function (error) {
              alert(error.code)
            })
        } catch (exception) {
          console.log(exception)
        }
      })

      $("#getAllTags").click(function (event) {
        window.JPush.getAllTags({ sequence: 2 },
          function (result) {
            $("#tagsResult").html(result.tags)
          }, function (error) {
            alert(error.code)
          })
      })

      $("#cleanTags").click(function (event) {
        window.JPush.cleanTags({ sequence: 2 },
          function (result) {
            alert(result.sequence)
            $("#tagsResult").html("")
          }, function (error) {
            alert(error.code)
          })
      })

      $("#setAlias").click(function (event) {
        var alias = $("#aliasText").val()
        window.JPush.setAlias({ sequence: 1, alias: alias },
          function (result) {
            $("#aliasResult").html(result.alias)
          }, function (error){
            alert(error.code)
          })
      })

      $("#getAlias").click(function (event) {
        window.JPush.getAlias({ sequence: 2 },
          function (result) {
            alert(JSON.stringify(result));
          }, function (error) {
            alert(error.code)
          })
      });

      $("#deleteAlias").click(function (event) {
        window.JPush.deleteAlias({ sequence: 3 },
          function (result) {
            alert(JSON.stringify(result));
          }, function (error) {
            alert(error.code)
          })
      });
    };
  
    document.addEventListener("deviceready", onDeviceReady, false);
    document.addEventListener("jpush.openNotification", onOpenNotification, false);
    document.addEventListener("jpush.receiveNotification", onReceiveNotification, false);
    document.addEventListener("jpush.receiveMessage", onReceiveMessage, false);

(HuminiOS) #14

使用这个接口获取 rid。


#15

我有调用啊,官方的demo,安卓下可以跑起来的,ios下不行,不知道问题出在哪里,也没有错误信息


#16

看插件文档,没有提示权限申请,应该就是没启动成功,不知道怎么解决了


(HuminiOS) #17
  1. 推送证书配置没,
  2. capability 推送点开没 。

#18

您看看有什么问题吗


#19

只用证书验证,应该是可以的吧


(HuminiOS) #20

没有问题。 加我 Q:380108184 我看看具体情况,