You can do this by using pubnub Push notification
- Enable the push notification on pubnub admin console and Set your certificates
- client side : enable push notification on the required channel
Adding Device to Channel
PNConfiguration *configuration = [PNConfiguration configurationWithPublishKey:@"demo"
subscribeKey:@"demo"];
self.client = [PubNub clientWithConfiguration:configuration];
[self.client addPushNotificationsOnChannels:@[@"wwdc",@"google.io"]
withDevicePushToken:self.devicePushToken
andCompletion:^(PNAcknowledgmentStatus *status) {
// Check whether request successfully completed or not.
if (!status.isError) {
// Handle successful push notification enabling on passed channels.
}
// Request processing failed.
else {
// Handle modification error. Check 'category' property to find out possible issue because
// of which request did fail.
//
// Request can be resent using: [status retry];
} }];
- Change your publish method
publish to APNS devices with the PubNub
4 . Important message formet
{ "pn_apns": { "aps" : {
"alert": "Game update 49ers touchdown",
"badge": 2
},
"teams" : ["49ers", "raiders"],
"score" : [7, 0]
},
"your_message" : {
"date" : "2014.05.20",
"foobar" : "Data that is not pertinent to devices"
}
}
For background message (iOS Mobile Push Gateway Tutorial)