Sencha touch 2 + Apple push notifications + Ext.device.Push

烂漫一生 提交于 2019-12-05 03:50:28

问题


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

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 + '"'
    //              });
    //                    }
    //        });
},

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?


回答1:


Make sure you included "notificationConfiguration":"debug" into your JSON config.




回答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/.

The most important steps are:

  • Configure applicationName, applicationId and bundleSeedId in package.json
  • Perform a manual entitlement on your app
  • Build the .pem certificate (or .p12) for push server correctly


来源:https://stackoverflow.com/questions/10750876/sencha-touch-2-apple-push-notifications-ext-device-push

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!