Sencha touch 2 + Apple 推送通知 + Ext.device.Push [英] Sencha touch 2 + Apple push notifications + Ext.device.Push

查看:22
本文介绍了Sencha touch 2 + Apple 推送通知 + Ext.device.Push的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I recently started developing with Sencha Touch 2, at the moment i'm creating an app that needs support for Apple Push Notifications.

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

So I've created the neccesary certificates at the Apple developer center and used them to package the application with the Sencha Touch SDK tools. All went well and I'm able to run this app on my device.

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

In the app I added a button to receive the device token. When I tap the button it executes the following code:

    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 收到任何消息.不会触发成功、失败或接收到的事件.这里有没有人设法让这个工作,或者我做错了什么?

When the Ext.device.Notificaion.show is uncommented, I get a message so I'm sure this piece of code gets executed. Now my problem is I don't get any message from the Ext.device.Push.register. No success, failure or received event gets fired. Has anyone over here managed to get this working, or what am I doing wrong?

推荐答案

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

I've post on my blog how to configure and build a Sencha Touch application for IOS Push Notifications - http://isolasoftware.it/2013/09/17/ios-push-notifications-using-sencha-touch-2/.

最重要的步骤是:

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

这篇关于Sencha touch 2 + Apple 推送通知 + Ext.device.Push的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆