appsflyer-react-native-plugin icon indicating copy to clipboard operation
appsflyer-react-native-plugin copied to clipboard

Improve documentation

Open mifi opened this issue 4 years ago • 8 comments

Maybe some of these are self explanatory, but I'm trying to setup this but I find some of the documentation is a bit vague:

  1. initSdk - when to call this? Do we need to make sure that initSdk promise has returned before we start calling other methods like trackAppLaunch, meaning we have to wait for it to return before calling AppRegistry.registerComponent('App', () => App);?
  2. initSdk resolves a result, what is this? an object?
  3. updateServerUninstallToken resolves with a success. When will this be false?
  4. updateServerUninstallToken Where to put this method call and what token to input? Should it be run after const token = await firebase.messaging().getToken(); ?

mifi avatar May 07 '20 12:05 mifi

Hi, Thank you for your message. We are currently working on improving the plugin and as a result, some parts of the documentation might not be totally up-to-date. To help you with your questions :

  1. initSDK is already calling trackAppLaunch, so there is no need to call if after. To measure sessions between background/foreground transitions in Android we listen to those transitions. In iOS, we cannot listen to those transitions, so we are using the app state, like mention in the doc. This is the only place where you need to call trackAppLaunch as following :
_handleAppStateChange = (nextAppState) => {
if (this.state.appState.match(/inactive|background/) && nextAppState === 'active') {
 if (Platform.OS === 'ios') {
  appsFlyer.trackAppLaunch();
 }
}
this.setState({appState: nextAppState});
};

2.For now, you can use initSDK without the promise. It has two callbacks, both returning a String, one with “success” and the other one with an error message. 3. For now, updateServerUninstallToken will always return success. 4.For iOS, you need to pass the device Token to updateServerUninstallToken, and for Android, you need to pass the firebase token. You can call it, as soon as you get both tokens and after AppsFlyer is initialized.

I hope this is more clear.

af-margot avatar May 12 '20 13:05 af-margot

Thanks for your clarifications.

  1. can we also call updateServerUninstallToken with the firebase token on iOS so that we can use the same code on both platforms? (as you suggest here). If not, which token to send to updateServerUninstallToken on ios?

mifi avatar May 15 '20 08:05 mifi

Hi,

Our uninstall measurement depends on Apple Push Notification for iOS and Firebase Messaging for Android. Then for iOS, you need to pass the device token to register to Apns services. You can use a third-party library to get this device token. Another option to implement the uninstall feature for iOS is to do it from the AppDelegate to automatically get the device token. More info here.

af-margot avatar May 18 '20 04:05 af-margot

Ok, so we cannot use FCM token on iOS too if using react-native-firebase, correct?

mifi avatar May 21 '20 04:05 mifi

Yes, correct. But you can get the APNs token with firebase using this API. Please note that this is only a suggestion and there are other ways to get the APNs token.

af-margot avatar May 26 '20 08:05 af-margot

To harp on the updateServerUninstallToken method some more, does that mean something like this should work?

let token: string | null = null
if (Platform.OS === 'android') token = await firebase.messaging().getToken()
if (Platform.OS === 'ios') token = await firebase.messaging().ios.getAPNSToken()
if (token) appsFlyer.updateServerUninstallToken(token, () => {})

Does this functionality require the Android and iOS steps in these guides as well? (FCM Server Key for Android, P12 Certificate upload for iOS)

mingyjongo avatar Jun 09 '20 18:06 mingyjongo

That's what I did. Note that firebase.messaging().ios.getAPNSToken() sometimes returns null, so it needs some retry or extra precautions. See https://github.com/invertase/react-native-firebase/issues/1990#issuecomment-631892469

mifi avatar Jun 21 '20 11:06 mifi

+1 for improving documentation.

I was surprised that initialization forced us to use callbacks, and then looking at the code I see that promises are also accepted.

I the documentation missing because it is not going to be matained or why is it not there as an alternative example?

diegodorado avatar Mar 03 '22 16:03 diegodorado

This issue is closed due to inactivity. If the issue continue, please open a new one.

github-actions[bot] avatar Dec 29 '22 12:12 github-actions[bot]