iOS-使用PubNub发送Apple推送通知
我正在将PubNub(一种允许设备相互发送消息的服务)集成到我的iOS应用程序中 我已按照页面上的说明进行操作: 我已在我的AppDelegate.m中注册推送通知:iOS-使用PubNub发送Apple推送通知,ios,apple-push-notifications,pubnub,Ios,Apple Push Notifications,Pubnub,我正在将PubNub(一种允许设备相互发送消息的服务)集成到我的iOS应用程序中 我已按照页面上的说明进行操作: 我已在我的AppDelegate.m中注册推送通知: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if ([[[UIDevice currentDevice] systemVersion] floa
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
[[UIApplication sharedApplication] registerForRemoteNotifications];
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge
|UIUserNotificationTypeSound
|UIUserNotificationTypeAlert) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
}
return YES;
}
-(void) application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSLog(@"Application registered for push notifications");
}
-(void) application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
NSLog(@"Device failed to register for push:");
}
-(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSLog(@"Received push");
}
我正在我的视图控制器中发送通知:
NSDictionary *push = @{@"pn_apns" :
@{@"aps" : @{
@"alert" : @"notification"
}
}
};
[self.pubNub sendMessage:@"sample" applePushNotification:push toChannel:[PNChannel channelWithName:@"test channel"] compressed:NO withCompletionBlock:^(PNMessageState state, id data) {
switch (state) {
case PNMessageSending:
NSLog(@"sending message");
break;
case PNMessageSendingError:
NSLog(@"error sending message");
break;
case PNMessageSent:
NSLog(@"message sent");
break;
default:
break;
}
}];
我通过回调收到发送的消息,但推送通知没有发送到第二台设备上 嘿!我看不到您将设备UUID与通道相关联。这在教程中提到过。试试看,如果不行,请随时联系我们support@pubnub.com同样,请随时查看我们昨天发布的新4.0 sdk!将有关您的问题的详细信息发送到support@pubnub.com:PubNub SDK版本、代码、子密钥,我们将帮助您并在这里发布公共安全答案。请在给我们的电子邮件中引用此SO链接。