Every time I receive a new notification the show an alert with the title of the push notification,
my setting is on OSNotificationDisplayTypeNone
sdk version 2.1.16
@hugoerg56 There have been a number of release after 2.1.16 that could have fixed this issue. Can you try our latest 2.3.5?
If you are still seeing an issue please make sure you are calling OneSignal initWithLaunchOptions from application:didFinishLaunchingWithOptions:
I have the same problem with 2.3.5 ,
I am using kOSSettingsKeyInFocusDisplayOption: @(OSNotificationDisplayTypeNone) but OneSignal still shows Alert.
When I enable logs via setLogLevel, it also alerts all the logs.
Although it does not happen always.
But if the device has the problem, the only solution is to re-install the app, restarting/disabling-enabling permissions wont have effect.
@ogres @hugoerg56 Can you run the following after OneSignal init to see what the value is currently set to?
NSLog(@"ONESIGNAL_ALERT_OPTION: %ld", [[NSUserDefaults standardUserDefaults] integerForKey:@"ONESIGNAL_ALERT_OPTION"]);
Setting the setLogLevel and seeing debugging dialogs is expected if you set the visualLevel above None.
Thanks.
I could not reproduce the issue since then, but if it still happens, I will let you know the details.
@jkasten2 I am getting this none stop today, for no reason :/ tried both 2.3.5 and 2.3.7 same issue.
OneSignal.initWithLaunchOptions(launchOptions, appId: App.oneSignalAppID, handleNotificationReceived: { (notification) in
print("Log1 \(UserDefaults.standard.integer(forKey: "ONESIGNAL_ALERT_OPTION"))")
PushNotificationRouter.sharedInstance.handleNotificationReceived(notification: notification!)
}, handleNotificationAction: { (result) in
print("Log2 \(UserDefaults.standard.integer(forKey: "ONESIGNAL_ALERT_OPTION"))")
PushNotificationRouter.sharedInstance.handleNotificationAction(result: result!)
}, settings: [
kOSSettingsKeyInFocusDisplayOption:OSNotificationDisplayType.none.rawValue,
kOSSettingsKeyAutoPrompt:false,
kOSSettingsKeyInAppAlerts: false
])
print("Log3 \(UserDefaults.standard.integer(forKey: "ONESIGNAL_ALERT_OPTION"))")
When testing, Log3 shows 0 for the values which is correct? but the other locations both logged 1 as the value :/
@hugoerg56 Was this after a fresh install on the device? Where else in your code did you print ONESIGNAL_ALERT_OPTION?
It happened again and I checked ONESIGNAL_ALERT_OPTION, its set to 1.
It was fresh install.
I still have the affected device, please let me know if you need more information.
I think I found a way to reproduce the issue.
kOSSettingsKeyInFocusDisplayOption = OSNotificationDisplayTypeNoneONESIGNAL_ALERT_OPTION is set to 0ONESIGNAL_ALERT_OPTIONNow you will see Push notification alert and if you check UserDefaults, it will contain ONESIGNAL_ALERT_OPTION=1
@ogres Thanks for the details. This is expected since UserDefaults.standard.removePersistentDomain will clear all of OneSignal's setting and stored data. You won't normally call this in a released app so I don't think this should be a concern.
I can't agree.
It does not seem right, that OneSignal takes configuration and then overrides it on the fly. There is no need for this at all, because only place to configure OneSignal is during init.
I think it should not read ONESIGNAL_ALERT_OPTION or configuration each time notification is received. Instead it should always use whatever was given in configuration.
Also, It's not rare to clear UserDefaults when user wants to logout/delete all the data.
I agree with @ogres as I've just seen this issue appear in one of my apps and I use UserDefaults.standard.removePersistentDomain as it is the best way of ensuring the defaults have been cleared (otherwise, you'd need to manually track and delete every key you used).
Would it be possible to get a method added to the SDK so that the kOSSettingsKeyInFocusDisplayOption flag can be set manually outside of the initiation? That way, I can re-set my display option after I've cleared the defaults...
@bendodson workaround would be to save it in UserDefaults again
@ogres @bendodson This setting doesn't need to be saved to storage so I'll change this to be a used from a variable only.
Ultimately, I am looking at creating a mechanism to control this on a per notification bases so the payload can used as part of the logic. Similar to userNotificationCenter:willPresentNotification:withCompletionHandler:. However in the mean time we can expose a public method to set the in focus display option.
I'll keep in mind that removePersistentDomain will be used in production app when making future changes to the SDK.
@ogres @bendodson Made these changes in commit 7862d527f147fc527672d529a046bd39e19b6627 which will go out with our 2.5.0 release.
It still shows notifications when the app in focus even though I set OneSignal.inFocusDisplayType = OSNotificationDisplayType.none @jkasten2
The latest version of ios sdk via cocoapods
Most helpful comment
@ogres @bendodson Made these changes in commit 7862d527f147fc527672d529a046bd39e19b6627 which will go out with our 2.5.0 release.