问题
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