Conversation
| */ | ||
| if (configuredApiKey != null) { | ||
| // Delete previous push token to avoid receiving push notifications originating from previous instance | ||
| FirebaseMessaging.getInstance().deleteToken().await() |
There was a problem hiding this comment.
Workaround 1:
During testing, it appears push notifications are still coming for the device with the new braze config (new API key), even though the campaign is configured for another application (API key)
| } | ||
|
|
||
| @Throws | ||
| private suspend fun initialize(config: ConfigData) { |
There was a problem hiding this comment.
The SDK creates the instance regardless of configuration validity - i.e when braze.xml is absent and programmatic configuration is not executed yet, the SDK throws warnings to the console that API_KEY is empty
| To prevent receiving the same push notification more than once, | ||
| it's required to unregister the previous device push token | ||
| */ | ||
| await UIApplication.shared.unregisterForRemoteNotifications() |
There was a problem hiding this comment.
Workaround 2:
Sometimes, after switching to another configuration, the same push notification is coming twice.
|
|
||
| // Remove references to the previous instance, so GC can deallocate it | ||
| brazeInstance = nil | ||
| BrazeReactBridge.deinitBraze() |
There was a problem hiding this comment.
Workaround 3:
After switching to another configuration, the push notifications are not coming at all (with workaround 2 in place).
| and before creating a new instance. | ||
| Otherwise, push notifications for the new instance won't work | ||
| */ | ||
| DispatchQueue.main.asyncAfter(deadline: .now() + delay) { |
There was a problem hiding this comment.
Workaround 4:
After switching to another configuration, the push notifications are not coming at all (with workarounds 2 and 3 in place).
There was a problem hiding this comment.
For some reason need to wait after de-initializing previous instance
Out of curiosity, did you experience this on both iOS and Android?
There was a problem hiding this comment.
The issue was observed only on iOS
| DispatchQueue.main.asyncAfter(deadline: .now() + delay) { | ||
|
|
||
| // A workaround for "Configuration" interfaces Swift<->Objective-C incompatibility | ||
| brazeInstance = BrazeInitWorkaround.initBraze(configuration) |
There was a problem hiding this comment.
Workaround 5:
"Configuration" protocol does not conform to "BRZConfiguration".
|
|
||
| #pragma mark - Setup | ||
|
|
||
| ++(void)deinitBraze { |
There was a problem hiding this comment.
Workaround 6:
Adding a patch file to enrich BrazeReactBridge with deinitBraze method which is required for Workaround 3
|
THANK YOU This is awesome, thank you so much for taking the time to propose such a thorough, well documented contribution. We are currently working in our private repositories on adding support for dynamically initializing the Braze SDK. We are still working on this, but we will have more to share soon. We are currently not set up to accept external contributions of this magnitude, so we will not be merging this. However, we will do the following:
|
Case Number: 00249678