appsflyer-react-native-plugin
appsflyer-react-native-plugin copied to clipboard
Improve documentation
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:
-
initSdk
- when to call this? Do we need to make sure thatinitSdk
promise has returned before we start calling other methods liketrackAppLaunch
, meaning we have to wait for it to return before callingAppRegistry.registerComponent('App', () => App);
? -
initSdk
resolves aresult
, what is this? an object? -
updateServerUninstallToken
resolves with asuccess
. When will this be false? -
updateServerUninstallToken
Where to put this method call and what token to input? Should it be run afterconst token = await firebase.messaging().getToken();
?
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 :
-
initSDK
is already callingtrackAppLaunch
, 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 calltrackAppLaunch
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.
Thanks for your clarifications.
- 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?
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.
Ok, so we cannot use FCM token on iOS too if using react-native-firebase
, correct?
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.
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)
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
+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?
This issue is closed due to inactivity. If the issue continue, please open a new one.