I am trying to integrate OneSignal into my app.
What I want is when user tap a notification to present desired ViewController modally. I implemented opening VC logic in handleNotificationAction while init of OneSignal.
The problem is that OneSignal still opens its WebView, and I don't want it to. Is there any way to disable opening WebView when user taps notification?
let onesignalInitSettings = [kOSSettingsKeyAutoPrompt: false]
OneSignal.initWithLaunchOptions(launchOptions,
appId: "myAppID",
handleNotificationAction: { result in
guard let payload = result?.notification.payload else { return }
guard let additionalData = payload.additionalData else { return }
guard let venueID = additionalData["internal"] as? String else { return }
DispatchQueue.main.async {
self.showVenueDetails(venueID)
}
},
settings: onesignalInitSettings)
OneSignal.inFocusDisplayType = .notification
OneSignal.promptForPushNotifications(userResponse: { accepted in
print("User accepted notifications: \(accepted)")
})
To unsubscribe from Chrome on Android when you receive a notification: Tap the notification when it is in your notification tray.
Send Your First Push NotificationNavigate to the OneSignal dashboard. Select Check Subscribed Users. If everything went well, you should see a green pop-up message indicating that the connection was successful. You can proceed to create your first notification by clicking on the blue Send a Message button.
Yes, add kOSSettingsKeyInAppLaunchURL: false to your onesignalInitSettings. This will open URL in default browser instead of UIWebView.
If you want to display your custom view then don't use the URL parameter in the payload. Instead, use custom key-value pair in additional data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With