I'm trying to implement Push-Notifications with this tutorial. Chat with PubNub works perfectly. I can also send and receive Push-Notifications with this script, but only with the development-certificate, so I submitted this to PubNub. (does anybody know why? I've created both Certificates for my App) When I open the App, I receive the Message with all Keys like I see it in the DebugConsole:
{ "message": "Asdas",
"pn_apns": {
"aps": {
"alert": "To Apple and PN Native devices!"
}
},
"senderId": "mySenderId",
"receiverId": "myReceiverId"
}
I'll show all the steps I think are relevant for Push-Notifications, so please say if I forgot something or I did something wrong.
didFinishLaunching
UIUserNotificationType types = (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert);
UIUserNotificationSettings *mySettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:mySettings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
PNConfiguration *configuration = [PNConfiguration configurationWithPublishKey:@"pub-key" subscribeKey:@"sub-key"];
self.client = [PubNub clientWithConfiguration:configuration];
[self.client addListener:self];
[self.client subscribeToChannels:@"myChannelId" withPresence:NO];
didRegisterForRemoteNotificationsWithDeviceToken
[self.client addPushNotificationsOnChannels:@[@"apns"] withDevicePushToken:deviceToken andCompletion:^(PNAcknowledgmentStatus *status) { }];
send a PubNub-Chat Message
NSDictionary * dict = @{@"aps": @{@"alert":@"To Apple and PN Native devices!"}};
[self.client publish:@{@"message" : @"Hello!", @"senderId" : @"abc123", @"receiverId" : @"abc124"} toChannel:@"myChannel" mobilePushPayload:dict withCompletion:^(PNPublishStatus *status) {}];