Steeve Steeve - 10 months ago 84
iOS Question

Cannot send/receive PubNub Push-Notifications to iOS

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.


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];


[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) {}];


I was to stupid to subscribe for the right Channel. At the didRegisterForRemoteNotificationsWithDeviceToken you should use your unique Channel ID, instead of @"apns"...

Thanks for your Help