[AC-1427] iOS registerForPushNotifications from background
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2014-07-24T08:18:43.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Appcelerator Modules, Titanium SDK & CLI |
Labels | n/a |
Reporter | Rainer Schleevoigt |
Assignee | Shuo Liang |
Created | 2014-07-17T11:48:21.000+0000 |
Updated | 2016-03-08T07:37:51.000+0000 |
Description
this is my code:
Ti.Network.registerForPushNotifications({
success : function(e) {
that.deviceToken = e.deviceToken;
Ti.App.Properties.setString('deviceToken', e.deviceToken);
},
error : function(e) {},
callback : function(e) {
console.log('||||||||||||||||||||||||');
console.log(e.data.alert);
},
types : [Ti.Network.NOTIFICATION_TYPE_BADGE, Ti.Network.NOTIFICATION_TYPE_ALERT, Ti.Network.NOTIFICATION_TYPE_SOUND] // [Ti.Network.NOTIFICATION_TYPE_ALERT]
});
If the app is running in foreground and I send a PN from web console it works like a charm: I see the message on console inside xcode.
But If I push the home button and the app runs in background and I send a PN, then I see the notification in statusbar. If I start the app now I aspect that the event 'callback' is fired and the property 'inBavkground' is set. In this case I would read the payload etc. But no event is fired. I ask me the purpose of this new property.
Hi, The behaviour you mentioned is normal. When you received a push notification, callback function will be fired. But the action of your callback function is output log in console, that is only supported for foreground app. When the app is in background, console.log or alert actions will not work. Once you switch the app to foreground, the action will appear. Regards, Shuo