Sencha touch 2 + Apple推送通知+ Ext.device.Push

时间:2012-05-25 08:14:54

标签: sencha-touch-2 apple-push-notifications javascript-framework devicetoken

我最近开始使用Sencha Touch 2进行开发,目前我正在创建一个需要支持Apple推送通知的应用。

因此,我在Apple开发人员中心创建了必要的证书,并使用它们将应用程序与Sencha Touch SDK工具打包在一起。一切顺利,我可以在我的设备上运行这个应用程序。

在应用程序中,我添加了一个按钮来接收设备令牌。当我点击按钮时,它会执行以下代码:

    Ext.device.Push.register({
        type: Ext.device.Push.ALERT | Ext.device.Push.BADGE | Ext.device.Push.SOUND,
        success: function (token) {
            console.log('# Push notification registration successful:');
            Ext.Msg.alert('    token: ' + token);
        },
        failure: function (error) {
            console.log('# Push notification registration unsuccessful:');
            Ext.Msg.alert('     error: ' + error);
        },
        received: function (notifications) {
            console.log('# Push notification received:');
            Ext.Msg.alert('    ' + JSON.stringify(notifications));
        }



    //    Ext.device.Notification.show({
    //        title: 'My Title',
    //        message: 'A message',
    //        style: "login",
    //        buttons: ["Cancel", "Login"],
    //        callback: function (button, values, options) {
    //              //When the user taps a button, show another notification
    //              Ext.device.Notification.show({
    //                   message: 'You typed: "' + values + '"'
    //              });
    //                    }
    //        });
},

当Ext.device.Notificaion.show被取消注释时,我收到一条消息,所以我确信这段代码会被执行。现在我的问题是我没有收到来自Ext.device.Push.register的任何消息。没有成功,失败或收到的事件被解雇。有没有人在这里设法让这个工作,或者我做错了什么?

2 个答案:

答案 0 :(得分:0)

确保将"notificationConfiguration":"debug"包含在您的JSON配置中。

答案 1 :(得分:0)

我在博客上发布了如何为IOS推送通知配置和构建Sencha Touch应用程序 - http://isolasoftware.it/2013/09/17/ios-push-notifications-using-sencha-touch-2 /。

最重要的步骤是:

  • 在package.json
  • 中配置applicationName,applicationId和bundleSeedId
  • 在您的应用上执行手动授权
  • 正确构建推送服务器的.pem证书(或.p12)