当前位置: 首页 > 知识库问答 >
问题:

当应用程序处于前台并收到OneSignal推送通知时,如何防止警报?

庄星汉
2023-03-14

当我的应用在前台时,会出现一个警报。如何防止在接收推送通知时出现这种情况?

共有3个答案

茅才
2023-03-14
匿名用户

默认情况下,当应用程序不聚焦时,OneSignal将通知显示为警报对话框。要更改此操作,请将值为OSNotificationDisplayTypeNotifyOSNotificationDisplayTypeNot的kOSSetting sKeyInFocus usDisplayOption更改为initSusLaunchOptions上的设置。

冯德佑
2023-03-14

对于Swift 3.0

// Initialize OngeSignal with Settings for Push Notifications
    OneSignal.initWithLaunchOptions(launchOptions, appId: Constants.OneSignalAppID, handleNotificationReceived: nil, handleNotificationAction: {
        (result) in
        // Do Something with Notification Result
    }, settings: [kOSSettingsKeyInFocusDisplayOption : OSNotificationDisplayType.none.rawValue])
李睿
2023-03-14

didfishlaunchingwithoptionsAppDelegate方法中,必须添加kossettingskeyinapplerts=NO

[OneSignal initWithLaunchOptions:launchOptions appId:ONESIGNAL_APPID handleNotificationReceived:nil handleNotificationAction:nil
                            settings:@{kOSSettingsKeyInAppAlerts:@NO}];

 类似资料: