Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UNUserNotificationCenterDelegate willPresent does't work with OneSignal #214

Closed
alexanderkhitev opened this issue Mar 24, 2017 · 4 comments

Comments

@alexanderkhitev
Copy link

alexanderkhitev commented Mar 24, 2017

I'm using OneSignal to send Push Notification, I ran into the problem that on iOS 10 the method func userNotificationCenter (_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) does not work, and UIAlertController appears, Instead of the standard Banner. What do I need to do to make this method work on iOS 10 and to display the standard banner?

Alert looks like this now
img_0823

@jkasten2
Copy link
Member

jkasten2 commented Mar 24, 2017

@alexsanderkhitev You can set kOSSettingsKeyInFocusDisplayOption to OSNotificationDisplayType.notification.rawValue. Pass this to the settings of initWithLaunchOptions to always show an notification / top screen banner.

You should still be able to use user​Notification​Center(_:​will​Present:​with​Completion​Handler:​) if you wish conditionally control how the notificaiton is displayed. Just make sure you set kOSSettingsKeyInFocusDisplayOption to None in this case so the OneSignal SDK does not display its own alert alongside your setting.

If you still are seeing an issue please make sure you are using our latest 2.4.3 SDK and share your code in your user​Notification​Center(_:​will​Present:​with​Completion​Handler:​) method.

@alexanderkhitev
Copy link
Author

alexanderkhitev commented Mar 24, 2017

@jkasten2 thanks for quick response.

I set it this way, but so notifications do not come when the application is in foreground

UPDATE: Yes, I'm using the latest version of OneSignal.

    OneSignal.initWithLaunchOptions(launchOptions, appId: appID, handleNotificationAction: { (notificationResult) in

        }, settings: [kOSSettingsKeyInFocusDisplayOption : "Notification"])

@jkasten2
Copy link
Member

@alexsanderkhitev It is a type so it should the following in Swift.

OSNotificationDisplayType.notification.rawValue

@alexanderkhitev
Copy link
Author

@jkasten2
thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants