0
votes

I'm using Cordova 2.0 and UrbanAirship's phonegap plugin.

I'm looking at sending push notifications to users from a webpage (not the UrbanAirship dashboard) and found these docs that lead me to believe it is possible.

Push Notifications, Android, iOS

I'm thinking that if I take in the message and use the API calls it should work.

My question has two parts, firstly do I need two separate calls for Android and iOS? And secondly, can I send notifications to a group of users who have selected a favourite thing within my app?

Many thanks.

1

1 Answers

1
votes

I am doing something similar, where I have built a page into the Wordpress admin for a client to send push notifications from there. It uses the Broadcast API and UA's PHP library. It is pretty simple using their library. You just include the library and then make a separate call for each platform like:

$airship = new Airship(APP_KEY, SECRET_KEY);
$airship->broadcast(array('android' => array('alert' => $msg)));
$airship->broadcast(array('aps' => array('alert' => $msg)));

If you want to send specific messages to users, you would need to have your app make a call to your server so you can log their APID (Android) or their Device Token (iOS). Then you can use UA's Push API to send messages. You just tac on an array of APIDs or Device Tokens, and you use the same PHP library. They also have libraries for other languages as well.