Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1427] iOS registerForPushNotifications from background

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2014-07-24T08:18:43.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAppcelerator Modules, Titanium SDK & CLI
Labelsn/a
ReporterRainer Schleevoigt
AssigneeShuo Liang
Created2014-07-17T11:48:21.000+0000
Updated2016-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.

Comments

  1. Shuo Liang 2014-07-24

    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

JSON Source