【发布时间】:2016-11-25 12:45:33
【问题描述】:
我可以向我的 IOS 设备发送推送通知。但是,当我单击该通知时,它只会打开应用程序。应用程序内不显示任何消息。
我使用的代码:
if (application.applicationState == UIApplicationStateActive) {
NSString *cancelTitle = @"Close";
NSString *showTitle = @"Show";
NSString *message = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Some title"
message:message
delegate:self
cancelButtonTitle:cancelTitle
otherButtonTitles:showTitle, nil];
[alertView show];
[alertView release];
} else {
//Do stuff that you would do if the application was not active
}
但无法在上述代码的帮助下显示我的消息。上面的代码仅在我的应用程序打开且处于前台状态时才有效,而不是仅显示此警报。
请帮忙。
谢谢。
【问题讨论】:
-
您拥有的代码与推送通知无关。您拥有的代码只是在应用处于活动状态时显示警报视图。你想做什么?
-
我在我的 IOS 设备上收到推送通知。我只想当我单击该推送消息时,它应该打开我的应用程序并向用户显示该消息。如果您使用适当的代码进行详细指导,将会很高兴。 @Teja Nandamuri
标签: ios push-notification apple-push-notifications uialertview uilocalnotification