嗨我用这个UNUserNotificationCenterDelegate来避免在应用程序处于这个功能的前台时发出警报通知
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler API_AVAILABLE(ios(10.0)){
completionHandler(UNNotificationPresentationOptionAlert);
}
但是我收到了两个选项Alert&旗帜 如何在应用程序处于前台时删除警报?
答案 0 :(得分:0)
你必须在willPresent方法中应用条件,检查应用程序的状态,如果State是UIApplecationStateForeGround则不执行任何操作,否则它们将遵循UNNotificationPresentationOptionAlert。
答案 1 :(得分:0)
我发现如何解决一个信号init的选项,以避免显示警告
[OneSignal initWithLaunchOptions:launchOptions appId:@"YOURE_KEY" handleNotificationReceived:nil handleNotificationAction:nil
settings:@{kOSSettingsKeyInAppAlerts:@NO}];
并且要显示为横幅,您必须添加此代码
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler API_AVAILABLE(ios(10.0)){
completionHandler(UNNotificationPresentationOptionAlert);
}