Saturday, June 29, 2024
HomeiOS Developmentios - Would there be any downside If I initialize the SDK...

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

[ad_1]

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

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

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

The code appears to be like one thing like this:

useEffect(() => {
  const listener = AppState.addEventListener('change', (standing) => {
    if (Platform.OS === 'ios' && standing === 'lively') {
          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 () =>  res === RESULTS.UNAVAILABLE; // Android or iOS < 14.5 - when no ATT we simply monitor
;

Which means that in observe, if I open the app, the SDK can 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]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments