MicrosoftDocs / appcenter-docs

content repo for Visual Studio App Center on docs.microsoft.com
https://docs.microsoft.com/appcenter/
Creative Commons Attribution 4.0 International
122 stars 321 forks source link

Programmatic change to secret ignored #1513

Closed paulio closed 9 months ago

paulio commented 9 months ago

I'm using the AppCenterBehaviour within Unity without setting any secrets. Before the AppCenterBehaviour Starts I set the AppCenterBehaviour.Settings.iOSSecret. However, when App Center starts it reports that there isn't a secret. [AppCenter] ERROR: -[MSACAppCenter canBeUsed]/741 App Center SDK hasn't been configured. You need to call [MSACAppCenter start:YOUR_APP_SECRET withServices:LIST_OF_SERVICES] first. or [AppCenter] ERROR: -[MSACAppCenter setUserId:]/562 AppCenter must be configured with a secret from application to call setUserId. Sure enough events, etc, are not sent. However, if I manually set the secret in the inspector it works. How are you supposed to set the secrets programmatically?


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

paulio commented 9 months ago

It turns out that setting the secret in the App Center Behaviour is the correct way to supply a secret. However, it's quite limiting if you support more than one App Center, e.g. different releases, Alpha, Beta, etc. To cut a long story short, the workaround is to;

  1. Disable the App Center Behavior (ACB)
  2. Remove all secrets from the ACB in the Inspector
  3. Add App Center Advanced Behavior and select the appropriate check box for Start plug-in from App Center Behavior
  4. In your code you can now access the ACB and change the ACB.Settings.
  5. then enable the ACB This should allow the ACB to start with the correct secret settings, which will then start the appropriate plug-in