customerio / customerio-expo-plugin

MIT License
11 stars 9 forks source link

Integrating with multiple workspaces (or accounts) #62

Closed euc-callum closed 1 year ago

euc-callum commented 1 year ago

Hi, I'm looking to integrate with multiple workspaces (or possibly multiple accounts) in Customer.io from within a single mobile app, depending on a user interaction when they login to the mobile app.

For context: we provide a single mobile application across multiple regions, and the user selects a specific region to utilise prior to logging in. Changing a region changes the configuration that is utilised by the mobile application. Events, data, and more are separated by region.

I am able to re-initialise the CustomerIO SDK utilising different siteId and apiKey values during runtime, but I appear to be unable to utilise rich push notifications in iOS across multiple workspaces (or accounts) as the siteId and apiKey are utilised at build time.

Is there an option to register multiple siteId and apiKey values at build time or a means of enabling this at runtime that I could utilise?

euc-callum commented 1 year ago

We've seen this tend to be handled in other forms of build time configuration via the use of arrays as configuration inputs.

For example intentFilters for Android and associatedDomains for iOS allow us to write code such as:

ios: {
  associatedDomains: regions.map(
    (region) => `applinks:${envConfig[region].appDomain}`,
  ),
intentFilters: regions.map((region: RegionCode) => ({
  action: 'VIEW',
  autoVerify: true,
  data: [
    {
      scheme: 'https',
      host: envConfig[region].appDomain,
      pathPrefix: '/mobile-link',
    },
  ],
  category: ['BROWSABLE', 'DEFAULT'],
})),
ami-aman commented 1 year ago

Hi @euc-callum

I apologize, but I don't believe it's feasible to re-initialize the CustomerIO SDK in the Notification Service Extension during runtime. The CustomerIO Expo plugin generates the Notification Service Extension during prebuild, utilizing the configurations set in app.json or app.config.json.

associatedDomains is used for universal links in iOS, while intentFilters is used for universal links in Android. However, it's uncertain if updating SiteID, ApiKey, and Region in NotificationServiceExtension during run-time would be possible by using associatedDomains and intentFilters.

euc-callum commented 1 year ago

Hi @ami-aman, thanks for your response!

I'm not suggesting utilising either associatedDomains or intentFilters to handle this, more providing examples of other forms of configuration that allow providing multiple variants of a configuration.

My question was more about whether it'd be possible for Customer.io to provide a similar means of configuration to enable working with multiple workspaces.

ami-aman commented 1 year ago

Hi @euc-callum

I apologize, but at the moment, our expo plugin does not offer a way to configure Site ID, API Key, and Region in the Notification Service Extension for multiple workspaces during run-time.

One possible solution could be to make modifications in the NotificationServiceExtension to handle workspace credentials. Based on certain conditions, the respective Site ID, API Key, and Region could be used to re-initialize the Customer.io SDK in Notification Service Extension. However, please note that the code may be reset when executing prebuild --clean.

euc-callum commented 1 year ago

Is this likely to be something that could sit within your roadmap? This is likely to become a blocker for us utilising Customer.IO in the future, if we're only able to use it for a single region.

Let me know if it is preferable for me to reach out via email to our Customer.IO success manager and link this issue.

ami-aman commented 1 year ago

I sincerely apologize for any inconvenience caused.

At present, this feature is not included in our roadmap, but I would be happy to submit a request to our team on your behalf. Additionally, you may consider opening a request with our Customer Success Manager and linking this issue for reference.

euc-callum commented 1 year ago

Thanks @ami-aman, we've opened a request for this and linked the issue 👍

levibostian commented 1 year ago

Closing this issue as it has been documented internally. The mobile team will prioritize it from there.