我有一个 Phonegap 应用程序,我可以在其中接收推送通知。我在有效负载中发送了一个“Pagekey”,它告诉应用在收到推送通知后应用启动后要打开哪个 HTML 页面。
我在- (BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
(片段)中执行以下操作
NSDictionary* extras = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
NSString *key = ((NSString*)[extras objectForKey:@"pagekey"]);//get the Pagekey
NSLog(@"key: %@", key); //prints out "2" (2 without the "")
//Load the HTML Page depending on the pagekey
self.viewController.wwwFolderName = @"www";
if([key isEqual:@"2"]){
NSLog(@"Im in the 2 branch");
self.viewController.startPage = @"winnings.html";
}else{
NSLog(@"Im in the else branch");//this branch is executed(unexpected behaviour)
self.viewController.startPage = @"index.html";
}
pagekey 最初是 JSON 数据,从推送通知服务器发送。任何人都知道如何正确比较字符串以便执行正确的分支?提前非常感谢!