在我的应用程序中,我从服务器收到多个推送通知。每个推送通知都有不同的数据,并且它将转到单独的 View
。在 AppDelegate
中,我曾经获取 PushNotifications 数据,但我如何发送单独的 View 取决于不同的推送通知
当我得到时。我以前也得到推送通知数据,
- (void)application:(UIApplication*)application didReceiveRemoteNotification:
(NSDictionary*)userInfo
如何解决这个问题,你能给我建议吗
最佳答案
userInfo 是字典,您将在下面的委托(delegate)方法中获得诸如消息、警报、声音信息等键值。
- (void)application:(UIApplication*)application didReceiveRemoteNotification:
(NSDictionary*)userInfo
{
if([userInfo[@"Message"] isEqualToString:@"View1"])
{
[self.navigationController pushViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"ViewController1"] animated:YES];
}
else if([userInfo[@"Message"] isEqualToString:@"View2"])
{
[self.navigationController pushViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"ViewController2"] animated:YES];
}
else
{
[self.navigationController pushViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"ViewController3"] animated:YES];
}
}
希望对你有帮助...!
关于ios - iOS 上的多个 PushNotifications,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30324792/