customerio / customerio-expo-plugin

MIT License
11 stars 9 forks source link

Missing env variable Region when building for iOS #61

Closed jbtheard closed 1 year ago

jbtheard commented 1 year ago

I'm trying to build for iOS and I get the following error:

❌  (ios/NotificationService/Env.swift:7:45)

  5 |     static var customerIOSiteId: String = "{{SITE_ID}}"
  6 |     static var customerIOApiKey: String = "{{API_KEY}}"
> 7 |     static var customerIORegion: Region = {{REGION}} // "us" or "eu"
    |                                             ^ cannot find 'REGION' in scope

How can I specify Region variable so that it's picked by the build ? I have tried to add it to app.config.ts but that wouldn't change a thing.

ami-aman commented 1 year ago

Hi @jbtheard

Thank you for reaching out. You can specify region in app.config.ts or app.json as required. If you are using app.config.ts then the configuration for env should look like:

.
.
ios: {
            pushNotification: {
              useRichPush: true,
              env: {
                  siteId: "someValueForSiteId",
                  apiKey: "someValueForApiKey",
                  region: "US" // change this to EU, if your workspace is in EU region.
               }
       }
 }
.
.

For more details, check out our docs here.

jbtheard commented 1 year ago

oh I missed that page perhaps you shouldn't have any doc in this repo and only point to the doc on customer.io domain ?

jbtheard commented 1 year ago

Just a suggestion here but rather than using specific env key as iOS param, couldn't we reuse the config available to JS ?

ami-aman commented 1 year ago

oh I missed that page perhaps you shouldn't have any doc in this repo and only point to the doc on customer.io domain ?

I see what you are saying @jbtheard ! Sorry for the confusion. I will talk with the team about it and see how best we can handle this case.

Just a suggestion here but rather than using specific env key as iOS param, couldn't we reuse the config available to JS ?

I am not sure what you mean by config available to JS. Could you help me understand this ?

jbtheard commented 1 year ago

so far, I have always used expo-constants to store api keys and configuration. I believe it exposes env variables available to both native iOS, Android, as well as the JS layer (used in your useEffect ).

So my recommendation would be to add a customerio key to extra in app.config.js with all required variables:

{
extra:{
  customerio: {
          siteId: 'mySiteId',
          apiKey: 'myApiKey',
          region: 'eu',
        },
  }
}

Note that it's more a convention than a fix to anything and I may be wrong with that one...

Note: I think Expo is working on a way to use env files for version 49

jbtheard commented 1 year ago

Please note that the local build does work OK now. Currently testing a remote build on Expo servers...

ami-aman commented 1 year ago

Many thanks for your thorough explanation. I can clearly see that using expo-constants can be a relief to the developers. I have taken your feedback and will share with the team.

levibostian commented 1 year ago

Closing because it seems the original issue has been resolved.

Feel free to comment back if this issue still persists.