I've searched other questions similar to this here and I can't find any that seem to actually work. What I'm trying to do is when the user opens the app from a local notification, I need it to execute some code (such as opening the UIMessageComposer or displaying a UIAlertView). Anyone have any idea on how I would do this? Just as a note it is a local notification not a push notification.
问问题
4117 次
2 回答
4
您需要在AppDelegate.m文件 中实现此方法
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
你可以做你想要的。
这是一个关于如何使用本地通知的好教程。http://www.appcoda.com/ios-programming-local-notification-tutorial/
于 2013-08-07T03:18:04.047 回答
0
用这个
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateActive) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Reminder"
message:notification.alertBody
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
// Set icon badge number to zero
application.applicationIconBadgeNumber = 0;
}
于 2016-02-02T10:56:00.483 回答