Am I correct in believing that the callback function is only executed if the app is actually currently open on the iPhone ?
This is the code I have in my app.js
// register for push notifications Titanium.Network.registerForPushNotifications({ types: [ Titanium.Network.NOTIFICATION_TYPE_BADGE, Titanium.Network.NOTIFICATION_TYPE_ALERT, Titanium.Network.NOTIFICATION_TYPE_SOUND ], success:function(e) { var deviceToken = e.deviceToken; label.text = "Device registered. Device token: \n\n"+deviceToken; Ti.API.info("Push notification device token is: "+deviceToken); Ti.API.info("Push notification types: "+Titanium.Network.remoteNotificationTypes); Ti.API.info("Push notification enabled: "+Titanium.Network.remoteNotificationsEnabled); }, error:function(e) { label.text = "Error during registration: "+e.error; }, callback:function(e) { var myjobid = e.data.jobid; alert('Notification received:' + myjobid); var Props = Titanium.App.Properties; Props.setString('notify', myjobid); } });My payload is like this:
aps => { badge => 3, jobid => "2513751", },If I'm actually in the app, when I send a notification to it the alert notification and the correct jobid displayed. I can then retrieve that jobid elsewhere in my app using this:
var myjobid = Props.getString('notify');However, if I'm not in the app, and I send my app a notification the badge changes correctly, but I don't see an alert and the Props getstring(jobid) returns nothing.
It's as if the callback isn't firing unless I'm in the app.. is that what it should do ?
Is there no way to deliver a payload unless I'm in the app ?
2 Answers
bump
i think you have to register to push service in the "success" case
Your Answer
Think you can help? Login to answer this question!