我可以找出在 iOS 上启动应用程序的事件吗?
我需要区分以下几点:
- 点击图标
- 横幅通知
- 警报通知
或者,我可以查看应用程序本地设置(设置为横幅或警报通知)吗?
Best Answer-推荐答案 strong>
要确定应用是否通过按下通知启动,您需要实现 2 个方法。
首先,在应用程序 didFinishLaunchingWithOptions 中,执行以下操作:
- (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions
if ([launchOptions valueForKey"UIApplicationLaunchOptionsRemoteNotificationKey"]) {
// Handle notification
}
第二:
-(void)applicationUIApplication *)application didReceiveRemoteNotificationNSDictionary *)userInfo {
if (application.applicationState == UIApplicationStateActive) {
// The app was open when a remote notification was received...
} else {
// The app was in the background and just came to the foreground in response to the user pressing the push notification
}
}
您可以使用以下方式查看已启用的通知类型:
UIRemoteNotificationType notificationTypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
但是,您无法区分横幅通知或警报通知。
关于ios - 查找启动应用程序 : banner notification, 警报通知或图标点击的事件?,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/11134775/
|