Titanium mobile / Apple Push notifications What is the most logical place to insert the callback

痴心易碎 提交于 2019-12-12 03:37:58

问题


Question,

What I want to achieve is to have a centralised place for the notifications to be received, so no matter on what window or tab a user is the notification will be received and callback functions to be fired.

If a project relies heavily on the Apple Push Notifications what would (In Titanium Mobile) be the best place to insert the code for the notification requests and callback.

I thought this would happen automatically but it does not, currently I have the registerForPushNotifications placed in a file that is included on every window & tab. But if a push notification is send then it is received on every tab, but if I change the tab the notification is again received.

So if I place the registerForPushNotifications on a included file the notification will be received numerous times even tough it is fired once.


回答1:


Based on what you've said about your code, you're having trouble because you have multiple execution contexts (i.e. every tab has a window with the url property to another JavaScript file). Rather than using multiple contexts, load up the windows in a single context (using at least CommonJS, and optimally Alloy). Then you can register your callback in app.js, or in a CommonJS module called from your app.js. Your problem wouldn't exist in that scenario.




回答2:


if you are using push notifications with ACS, look here http://developer.appcelerator.com/question/135751/acs---push-notifications---tutorial

more information here

http://blog.teemusk.com/2012/05/building-server-push-notifications-with-appcelerator-titanium-cloud/



来源:https://stackoverflow.com/questions/14231470/titanium-mobile-apple-push-notifications-what-is-the-most-logical-place-to-ins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!