-
Notifications
You must be signed in to change notification settings - Fork 263
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
Get correct Data
value from OneSignal.getDeviceState().pushToken
which is a String
#1069
Comments
@JayMehta97 Hello thank you for reaching out. I recommend implementing the following method in your AppDelegate: This will be called after the user accepts the push prompt and provides the deviceToken which you can then forward to the other SDK. |
I tried with that method but the application:didRegisterForRemoteNotificationsWithDeviceToken: is not getting called if I just add the Oneginal SDK using SPM. If I remove that |
Odd that method is called for me when using the XCFramework repo and Swift Package Manager. Are you able to link an example project that reproduces the issue? |
Hi, we're facing the same issue here with SwiftUI TLDR; There's an easy way to reproduce the bug:
@main
struct Test_Intercom_OneSignalApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
import SwiftUI
import OneSignal
import Foundation
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
//MARK: OneSignal initialization
OneSignal.setLogLevel(.LL_DEBUG, visualLevel: .LL_NONE)
OneSignal.initWithLaunchOptions(launchOptions)
OneSignal.setAppId("your_onesignal_app_id")
OneSignal.setNotificationOpenedHandler( { openedEvent in
//
})
OneSignal.promptForPushNotifications(userResponse: { accepted in
//
})
return true
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
//
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
//
}
}
|
@Sml995 Thanks for the details and digging in. I believe you are correct that PR #1091 will fix the issue with your AppDelegate |
Thanks for the quick feedback @jkasten2, the sooner the better ahah ! |
Getting back on this after release v3.11.2 |
Description:
We are adding another 3rd party SDK for chat which provides PN for chat specific features. This SDK also requires
deviceToken
to setup remote push notifications. So in our current users device we have already taken remote notification access using OneSignal SDK. How do I givedeviceToken
to the new SDK usingOneSignal.getDeviceState().pushToken
? Can I convert the pushToken (String) to correctdeviceToken
(Data)?Environment
iOS version - 14.8.1
OneSignal SDK version - 3.5.3
Using OneSignal SDK via SPM
The text was updated successfully, but these errors were encountered: