playerduel フレームワークをサポートするアプリケーションを開発しています。2 人のプレーヤーが互いに遊ぶことができます。人は別の人に挑戦を送ることができます。私は次のドキュメントに従います。 https://docs.urbanairship.com/display/DOCS/Getting+Started%3A+iOS%3A+Push
上記のドキュメントで説明されているように、(テスト用に) コマンド ラインから送信すると通知を受け取ることができます。しかし、ゲームをするとき。Playerdual は、ある人が別の人にチャレンジを送信したときに通知を送信できません。
appdelegate コード:-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Init Airship launch options
NSMutableDictionary *takeOffOptions = [[[NSMutableDictionary alloc] init] autorelease];
[takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey];
// Create Airship singleton that's used to talk to Urban Airship servers.
// Please populate AirshipConfig.plist with your info from http://go.urbanairship.com
[UAirship takeOff:takeOffOptions];
// Register for notifications
[[UAPush shared]registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)];
// Override point for customization after application launch.
self.appStarted = YES;
UIImage *bgImage= [UIImage imageNamed:@"default.png"];
[PlayerDuel initializeWithGameKey:@"gamekey" andBackground:bgImage
andDelegate:[navigationController.viewControllers objectAtIndex:0] andOrientation:UIInterfaceOrientationPortrait];
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSLog(@"deviceToken:- %@",deviceToken);
// Updates the device token and registers the token with UA
[[UAPush shared] registerDeviceToken:deviceToken];
[PlayerDuel registerDeviceToken:deviceToken];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
for (id key in userInfo) {
NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
}
NSLog(@"remote notification: %@",[userInfo description]);
NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];
NSString *alert = [apsInfo objectForKey:@"alert"];
NSLog(@"Received Push Alert: %@", alert);
NSString *sound = [apsInfo objectForKey:@"sound"];
NSLog(@"Received Push Sound: %@", sound);
NSString *itemName = @"my app";
NSString *messageTitle = [apsInfo objectForKey:@"alert"];
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateActive){
AudioServicesPlaySystemSound(1007);
[self _showAlert:messageTitle withTitle:itemName];
}
else{
UIViewController *viewController = navigationController.visibleViewController;
// NSLog(@"Controller Name:- %@",viewController);
[viewController.view reloadInputViews];
[viewController playerDuelStartGame:nil];
}
NSString *badge = [apsInfo objectForKey:@"badge"];
NSLog(@"Received Push Badge: %@", badge);
}