OneSignal-Flutter-SDK
OneSignal-Flutter-SDK copied to clipboard
Multiple schemes/flavours - Embedded binary's bundle identifier is not prefixed with the parent app's bundle identifier
I am trying to integrate the OneSignal SDK with a Flutter iOS app having multiple schemes or flavors, i.e., experimental and production. The configuration only works fine with the production scheme. Is there any guidance or documentation on how to configure OneSignal for multiple schemes?
For more configuration, we have different bundle identifiers for experimental and production. For production: com.xxxx.app For experimental: com.xxxx.app.exp
I tried creating separate targets for notification services extension i.e. OneSignalNotificationServiceExtension for production and ExpOneSignalNotificationServiceExtension for experimental which contains separate identifiers as prefix.
any luck? π
any solution??
I'm not good at English, so please overlook any awkward sentences.
Following the setup guide at https://documentation.onesignal.com/docs/flutter-sdk-setup, proceed with configuring the Add App Groups option using the Optional method.
In the Info.plist of OneSignalNotificationServiceExtension, I want to add the following:
<key>OneSignal_app_groups_key</key>
<string>group.com.example$(appIdSuffix).onesignal</string>
However, since appIdSuffix is provided through dart-defines, the following steps are necessary:
Create a config file to use environment variables defined with dart-defines
Debug.xcconfig
#include? "Pods/Target Support Files/Pods-OneSignalNotificationServiceExtension/Pods-OneSignalNotificationServiceExtension.debug.xcconfig"
#include "../Flutter/Generated.xcconfig"
Release.xcconfig
#include? "Pods/Target Support Files/Pods-OneSignalNotificationServiceExtension/Pods-OneSignalNotificationServiceExtension.release.xcconfig"
#include "../Flutter/Generated.xcconfig"
Including "../Flutter/Generated.xcconfig" makes variables defined with dart-defines available!
Modify to load the created config file
Change the Configuration File in OneSignalNotificationServiceExtension to load the Debug.xcconfig and Release.xcconfig created.
Specify the Bundle Identifier of OneSignalNotificationServiceExtension
TARGETS -> OneSignalNotificationServiceExtension -> Build Settings
Replace Product Bundle Identifier with com.example$(appIdSuffix).OneSignalNotificationServiceExtension
Add OneSignal_app_groups_key to Info.plist of OneSignalNotificationServiceExtension
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.usernotifications.service</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).NotificationService</string>
</dict>
<key>OneSignal_app_groups_key</key>
<string>group.com.example$(appIdSuffix).onesignal</string>
</dict>
</plist>
It seems to be working well with these settings!
any solution???
It's a bit complicated, but this seems to be the only way for now. Has anyone found a better way?
- in oneSignal -> buildsettings define a
user-define ->multiple valueswith all you env and bundleID, give it unique name, in my case BUNDLE_ID - in project.pbxproj search and change all .OneSignalNotificationServiceExtension to =>
PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_ID).OneSignalNotificationServiceExtension";
ref :: https://github.com/OneSignal/OneSignal-iOS-SDK/issues/324#issuecomment-475034377
Any solution?