ios – Would there be any drawback If I initialize the SDK each time the app turns to an “energetic state”?

[ad_1]

I’m utilizing the react-native-permissions package deal as a way to obtain a consent from the person earlier than initializing the Fb SDK.

Since iOS 15 although, for the app monitoring transparency modal to indicate up we now have to request for permission, every time the app state standing adjustments to “energetic”. That is in accordance to the docs of the package deal.

Would there be any drawback if I do the initialization of the SDK every time the app state turns to “energetic”?

The code appears to be like one thing like this:

useEffect(() => {
  const listener = AppState.addEventListener('change', (standing) => {
    if (Platform.OS === 'ios' && standing === 'energetic') {
          const userAllowsTracking = await requestTrackingPermission();
          if (!userAllowsTracking) return;

          const isTrackingEnabled = await Settings.setAdvertiserTrackingEnabled(true);
          if (!isTrackingEnabled) return;

          Settings.initializeSDK();
    }
  });

  return listener.take away;
}, []);


const requestTrackingPermission = async () => ;

Because of this in apply, if I open the app, the SDK might be initialized offered that I gave my consent to ATT modal, then I put it in a background state after which if I put it again in a foreground state, the initialization will run once more.

Will this have an effect on how the SDK works?

Thanks!

[ad_2]

Leave a Reply