didomi / react-native

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

Feature-request : Add asynchronous on setUserWithHashAuth method #119

Open Thomas-TF1 opened 2 months ago

Thomas-TF1 commented 2 months ago

Hello,

I have an issue with setUserWithHashAuth method. It seems that this method is not promisable. I am quering shouldUserStatusBeCollected method further in my app so I would like to synchronize it setUserWithHashAuth method.

Is it possible to make it promisable?

pmerlet-at-didomi commented 2 months ago

Hello, currently the method is not promisable, but the user synchronization operation itself is asynchronous. You have to listen to SYNC_READY and SYNC_ERROR events to be notified when synchronization is complete:

Didomi.addEventListener(DidomiEventType.SYNC_READY, async(data: SyncReadyEvent) => {
    console.log('Sync is ready');
    // Resolve promise
});
Didomi.addEventListener(DidomiEventType.SYNC_ERROR, async(data: string) => {
    console.log('Sync error, reason: ' + data);
    // Resolve or fail promise
});

Didomi.setUserWithHashAuth(...);

Changing it in the SDK would be complicated, as it would be a breaking change for clients already using this method.