didomi / react-native

Didomi SDK for React Native
Other
9 stars 2 forks source link

Change the Notice Id in Runtime #87

Closed yubarajoli77 closed 12 months ago

yubarajoli77 commented 1 year ago

I want to test different notices with notice Id, for this I accept the notice id from ui and save it in the local storage then use it. Once applied I clear the user consent and restart the app to initialize the sdk with new notice id. But it didn't work. It always show the stuffs (consent content) from the first notice Id.

Note:- In expo dev client it's working with killing the client and run it again.

const noticeId = getDidomiNoticeId();

  await Didomi.initialize(
    "API Key",
    undefined,
    undefined,
    undefined,
    false,
    undefined,
    noticeId,
  );

I call this from the index.js.

Is it possible to change the notice Id in runtime? How?

There is a mention of 60 min. cache time for config here. Is there any way to clear this cache?

yubarajoli77 commented 1 year ago

For those who may face this problem in future, I do the following to change the notice id in run time.

  1. Use notice Id in async storage (saved below in step 3) or default notice id during app start in SDK initialization.
  2. Take input new noticeId.
  3. On button click clear the consents and persist the notice id in async storage.

But we need to restart the app to use the new notice id, because the init is one time call and it is persisted for 60 min.

crebillon commented 12 months ago

Hi Yuba

Charlotte from Didomi's technical support here.

Indeed we don’t support using several API keys / notice IDs simultaneously. That is a feature request in our backlog.

You could use the reset function to clear the user consent status and the notice would indeed be surfaced again.

Could you please detail your use case for wanting to support several notices? Feel free to reach out to support@didomi.io for further assistance with a detailed use case.