在iOS中单击本地通知时不要打开应用程序
当我点击来自通知中心的本地通知时,我想阻止它打开我的应用程序,也就是说,当点击通知时,除了清除它之外,不应该发生任何事情。你知道怎么做吗?苹果肯定会拒绝这样的应用。 但下面是你们可以做什么,若你们想做这样的事情,但这将打开应用程序 在在iOS中单击本地通知时不要打开应用程序,ios,objective-c,uilocalnotification,Ios,Objective C,Uilocalnotification,当我点击来自通知中心的本地通知时,我想阻止它打开我的应用程序,也就是说,当点击通知时,除了清除它之外,不应该发生任何事情。你知道怎么做吗?苹果肯定会拒绝这样的应用。 但下面是你们可以做什么,若你们想做这样的事情,但这将打开应用程序 在-(void)application:(UIApplication*)application didReceiveMemoteNotification:(NSDictionary*)userInfo{,有以下内容 - (void)application:(UIApp
-(void)application:(UIApplication*)application didReceiveMemoteNotification:(NSDictionary*)userInfo{
,有以下内容
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
//home button press programmatically
UIApplication *app = [UIApplication sharedApplication];
[app performSelector:@selector(suspend)];
//exit app when app is in background
exit(0);
}
简而言之,在从push打开应用程序时,请关闭该应用程序。我知道这篇文章很旧,但我是在自己想办法时发现的。我想我会更新,以防其他人碰到它 我正在与Swift一起进行Project 21黑客攻击,其中一个挑战要求您在通知中设置“稍后提醒我”选项。显然,在这种情况下打开应用程序是没有用的,所以我也尝试着解决这个问题 这是我发现的一种非常简单的方法。注册类别时,只需删除一段代码 例如:
func registerCateories() {
let center = UNUserNotificationCenter.current()
center.delegate = self // Any messages get sent back to us
let show = UNNotificationAction(identifier: "show", title: "Tell me more", options: .foreground)
let remindMeLater = UNNotificationAction(identifier: "remindMeLater", title: "Remind me later...")
let category = UNNotificationCategory(identifier: "alarm", actions: [show, remindMeLater], intentIdentifiers: [], options: [])
center.setNotificationCategories([category])
}
从本地通知中点击的两个选项是show
和remendmelater
。请注意show
有选项:
。这是单击时强制打开应用程序的原因。删除该选项(如remendmelater
)即可解决问题
稍后在代码中,您可以根据userNotificationCenter
函数中的response.actionIdentifier
调用不同的函数,以使点击实际执行某些操作
希望这有帮助!你为什么要这样做?不可能,你不能这样做。这就是我从许多帖子中了解到的,该应用程序将被拒绝。但仍想确认。谢谢如果我想在单击通知后打开特定视图,我如何在didReceiveLocalNotification功能中做到这一点?请注意,我是nt以打开特定视图而不是特定视图tab@bash当前位置转到其他视图还需要帮助吗?不,谢谢。我自己做的