Struggling to find a working example or a document that explains how to set contentful app installation params. I can see how to get them from the SDK but settings them i cant.
any help is much appreciated.
Struggling to find a working example or a document that explains how to set contentful app installation params. I can see how to get them from the SDK but settings them i cant.
any help is much appreciated.
Late answer but i also struggled with it. I found a tutorial here: https://dev.to/wiommi/how-i-built-a-contentful-app-combined-with-commerce-js-iii-33fo
They are added manually in ConfigScreen.tsx
You need to add them to your interface
export interface AppInstallationParameters {}
fx:
export interface AppInstallationParameters {
apiKey?: string;
projectId?: string;
}
And then set them manually with fx.
setParameters({ ...parameters, [PARAMETERNAME]: [PARAMETERVALUE] });
Most likely your app has a Config Location which means you are building UI that will be shown to the user during and after installation of your app. In this location, there is an SDK method called
sdk.app.onConfigure
. This method takes a function which will return an object which is calledtargetState
.targetState
documentation can be found here.Let's take a React Config app as an example where we will set
{foo: 'bar'}
as our installation parameters:In the example above, when a user hits "Install" or "Save" on the app's Config location, the installation parameter object of
{foo: 'bar'}
will be saved and can then be accessed in other app locations via the SDK.On the off chance you are purely using the API to create or modify an
AppInstallation
, you can use the Content Management API to update the app'sparameters
as described in the documentation here.