When prebuilding with expo 54 and v0.23.0, the crisp expo module adds the didRegisterForRemoteNotificationsWithDeviceToken on the appDelegate of the app without calling super, preventing expo notification from working.
The request to register for notification also happens too early causing the permission dialog to appear on launch of the app, leaving no control to the hosting app about when to ask for it.
import Expo
// @generated begin react-native-crisp-chat-sdk-swift - expo prebuild (DO NOT MODIFY) sync-cf002978639482214f88d4756d2925f629b1443b
import Crisp
// @generated end react-native-crisp-chat-sdk-swift
import React
import ReactAppDependencyProvider
@UIApplicationMain
public class AppDelegate: ExpoAppDelegate {
var window: UIWindow?
var reactNativeDelegate: ExpoReactNativeFactoryDelegate?
var reactNativeFactory: RCTReactNativeFactory?
public override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
let delegate = ReactNativeDelegate()
let factory = ExpoReactNativeFactory(delegate: delegate)
// @generated begin react-native-crisp-chat-sdk-swift-call - expo prebuild (DO NOT MODIFY) sync-dbf293b8b9903ac846b76ab269fda4638914fe44
// Crisp SDK Configuration
CrispSDK.configure(websiteID: "xxxxxxx")
DispatchQueue.main.async {
application.registerForRemoteNotifications() <================= we use expo notification, and this fires even before we have asked for permissions
}
// @generated end react-native-crisp-chat-sdk-swift-call
delegate.dependencyProvider = RCTAppDependencyProvider()
reactNativeDelegate = delegate
reactNativeFactory = factory
bindReactNativeFactory(factory)
#if os(iOS) || os(tvOS)
window = UIWindow(frame: UIScreen.main.bounds)
factory.startReactNative(
withModuleName: "main",
in: window,
launchOptions: launchOptions)
#endif
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
// Linking API
public override func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
return super.application(app, open: url, options: options) || RCTLinkingManager.application(app, open: url, options: options)
}
// Universal Links
public override func application(
_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
) -> Bool {
let result = RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler)
return super.application(application, continue: userActivity, restorationHandler: restorationHandler) || result
}
// @generated begin react-native-crisp-chat-sdk-swift-push-method - expo prebuild (DO NOT MODIFY) sync-839ff9b638cc569c643d943395b74ee2a8a63e54
public override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
CrispSDK.setDeviceToken(deviceToken) <========== this should call super so that other class can receive the token.
}
// @generated end react-native-crisp-chat-sdk-swift-push-method
}
class ReactNativeDelegate: ExpoReactNativeFactoryDelegate {
// Extension point for config-plugins
override func sourceURL(for bridge: RCTBridge) -> URL? {
// needed to return the correct URL for expo-dev-client.
bridge.bundleURL ?? bundleURL()
}
override func bundleURL() -> URL? {
#if DEBUG
return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: ".expo/.virtual-metro-entry")
#else
return Bundle.main.url(forResource: "main", withExtension: "jsbundle")
#endif
}
}
When prebuilding with expo 54 and v0.23.0, the crisp expo module adds the didRegisterForRemoteNotificationsWithDeviceToken on the appDelegate of the app without calling super, preventing expo notification from working.
The request to register for notification also happens too early causing the permission dialog to appear on launch of the app, leaving no control to the hosting app about when to ask for it.