Phonegap- Support for push notification

2019-04-24 13:48发布

问题:

I am analyzing phonegap usage for 4 mobile apps which will be created for

  • iOS (iPhone & iPad 4.2.1+)
  • Android (2.2+)
  • Blackberry(5.0+)
  • Windows phone (7+)

I could not find native support for push notifications in phonegap. Though I could google for push notification support for iOS and Android using different frameworks like pushwoosh and urban air.

Is there a common framework which can address push notifications for all the above mentioned platforms?

回答1:

By now, there's a Push Notification Plugin for Cordova/Phonegap available: Cordova Push Notifications Plugin.

It currently supports Android, iOS and Windows Phone 8.

I know that it is still not the common framework you wished for, but at least it accommodates these 3 platforms, which means you don't have to deal with separate plugins for each of these platforms anymore, as it's been the case before.



回答2:

There is no native support in phonegap for push notifications. Since these vary by platform, there are plugins, though.

You'll have to find a plugin for each platform you want. Here's a plugin for Android: https://github.com/marknutter/GCM-Cordova and here's one for iOS: https://github.com/phonegap/phonegap-plugins/tree/master/iOS/PushNotification I didn't find plugins for Windows7 or Blackberry, but all I did was a cursory search.

As mentioned above, there are services that provide some level of cross platform compatibility and provide server side APIs, so that you can send push to devices via a REST call (or something similar). These services also may provide some level of phonegap integration (via plugins).

Here are the services I have found that support the 4 platforms you mentioned:

  • Urban Airship: http://urbanairship.com/
  • Pushwoosh: http://pushwoosh.com/
  • Xtify: http://xtify.com/ (now an ibm company, here's the platforms they support: http://developer.xtify.com/display/sdk/Download+the+IBM+Push+Notification+SDKs )


回答3:

I would use the Urban Airship plugins for Android and iOS.

http://urbanairship.com/lp/urban-airship-phonegap-plugins/



回答4:

As an alternative to push notifications you may keep a streaming connection open and receive your notifications there. Obviously it is required that the application is kept alive for you to receive such messages.

If you think this is a viable solution for your needs you may try Lightstreamer: it works with PhoneGap on the cited platforms without the need of any plugin.

If interested take a look here: http://blog.lightstreamer.com/2012/08/lightstreamer-in-phonegap-app.html

[disclaimer: I'm a developer @ Lightstreamer]