Skip to content

Instantly share code, notes, and snippets.

@matzew
Created March 14, 2013 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matzew/3d7f9915afd8f6705da5 to your computer and use it in GitHub Desktop.
Save matzew/3d7f9915afd8f6705da5 to your computer and use it in GitHub Desktop.
Push for different mobile OS versions, for one "server" Push app...
@Test
public void sendNotificationTo_iOS_and_Android() {
// CREATE push app:
PushApplication pa = new PushApplicationImpl();
pa.setDescription("Test Push App");
pa.setName("All The Thingz");
// iOS app:
iOSApp pusher = new iOSApp();
pusher.setAppleAppId("net.wessendorf.Pusher");
pusher.setCertificate("/path/to/cert.p12");
pusher.setPassphrase("foo");
// add the iOS app:
pa.addMobileApplication(pusher);
// android app:
AndroidApp todoApp = new AndroidApp();
todoApp.setGoogleAPIKey("SOME-AWESOME-KEY");
// add the Android app:
pa.addMobileApplication(todoApp);
// register Push-App it with "server":
pushMgr.registerPushApplication(pa);
// send the message to all devices/mobile apps, for this Push app"
Sender sender = new SenderImpl();
sender.sendMessageToApplications("Yo, dude!", pushMgr.getPushApplications());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment