Tuesday, 15 February 2011

javascript - Dealing with titanium Push notifications ios -



javascript - Dealing with titanium Push notifications ios -

here code:

titanium.network.registerforpushnotifications({ types: [ titanium.network.notification_type_badge, titanium.network.notification_type_alert ], success:function(e) { var devicetoken = e.devicetoken; ti.api.info("push notification device token is: "+devicetoken); alert('device token is' +e.devicetoken); ti.api.info("push notification types: "+titanium.network.remotenotificationtypes); ti.api.info("push notification enabled: "+titanium.network.remotenotificationsenabled); }, error:function(e) { ti.api.info("error during registration: "+e.error); }, callback:function(e) { // called when force notification received. //titanium.media.vibrate(); var info = json.parse(e.data); var badge = data.badge; if(badge > 0){ titanium.ui.iphone.appbadge = badge; } var message = data.message; if(message != ''){ var my_alert = ti.ui.createalertdialog({title:'', message:message}); my_alert.show(); } } }); }

the callback function:

callback:function(e) { // called when force notification received. //titanium.media.vibrate(); var info = json.parse(e.data); var badge = data.badge; if(badge > 0){ titanium.ui.iphone.appbadge = badge; } var message = data.message; if(message != ''){ var my_alert = ti.ui.createalertdialog({title:'', message:message}); my_alert.show(); } } });

is fired when force notification recieved when app running in foreground.

question , if have 2 files:

app.js -> newwindow.js

and in newwindow.js , still receive force notifications? (if code above pasted in app.js?)

2) when recieve force notification when app running in background, how can write callback method it, can tell app notification

3) best way of handling different notifications, i.e. need open different windows, when in background mode?

notification 1 - > win1.js notification 2 - > win2.js notification 3 - > win3.js

first of should implement in app(it seems copied docs) , see how force notification appear create every thing lot clear.

the callback have written above fetch message have send using force notification.

as part 2 of question : 1 time user clicks on force received app come foreground , callback automatically called.

and handle different notifications, there never different force notifications, there single force notification.you have parse info , have deed according condition. can modify force message , open window according it.

javascript notifications titanium

No comments:

Post a Comment