Pushplugin-无法注册设备(IOS)

时间:2014-07-28 04:38:07

标签: ios cordova cordova-3 cordova-plugins phonegap-pushplugin

我正在使用Phonegap Pushplugin进行推送通知。在两种方法中添加了日志。 didRegisterForRemoteNotificationsWithDeviceToken方法永远不会执行。它甚至没有在didFailToRegisterForRemoteNotificationsWithError失败。不知道这里有什么问题。

我将IOS分发证书(非APN)上传到类固醇构建服务并将APN Prod配置文件上传到AdHoc构建。我收到推送通知的提示,我可以看到为我的应用启用了通知。问题是,我没有得到令牌。

查看debugging steps

的以下链接

Plugin link

我使用以下代码进行注册。

function registerDevice(){
    var pushNotification = window.plugins.pushNotification;
    pushNotification.register(
                              tokenHandler,
                              errorHandler, {
                                  "badge":"true",
                                  "sound":"true",
                                  "alert":"true",
                                  "ecb":"onNotificationAPN"
                              });
}

var onNotificationAPN = function(event) {
    var pushNotification = window.plugins.pushNotification;

    if ( event.alert )
    {
        navigator.notification.alert(event.alert);
    }

    if ( event.sound )
    {
        var snd = new Media(event.sound);
        snd.play();
    }

    if ( event.badge )
    {
        pushNotification.setApplicationIconBadgeNumber(successHandler, errorHandler,
                                                       event.badge);
    }
}

function tokenHandler (result) {
    steroids.logger.log("Tokenhandler called with result");
    steroids.logger.log(result);

    alert(result);

}

function errorHandler (error) {
    steroids.logger.log("errorHandler called with result");
    steroids.logger.log(error);
    alert('error = ' + error);
}

感谢任何帮助。

更新 - 2014年7月30日

我下载了PersistentConnectionLogging.mobilecondig,我看到了生成的令牌。我可以使用此令牌向手机发送通知。

tokenHandler和onNotificationAPN仍然没有被解雇。问题显然出现在Cordova方面或我的Javascript中。

这个插件是否适用于Cordova 3.1 / 3.5?令人沮丧的是,这个插件没有社区支持。

任何想法。

1 个答案:

答案 0 :(得分:0)

以下是我实施推送通知的方式:

  1. 处理证书。 Tutorial
  2. 注册并获取令牌。 Tutorial
  3. 使用NSUserDefaults存储令牌。
  4. 创建一个自定义插件,并通过使用JS桥创建自定义插件,将令牌从objective-c传递给javascript。 Tutorial
相关问题