Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onInstallConversionData dosen't return onAppOpenAttribution when mounting #53

Closed
katjastrof opened this issue Oct 12, 2018 · 9 comments
Closed
Labels

Comments

@katjastrof
Copy link

I get a success callback from onInstallConversionData every time opening the app. I can get both callbacks of type onInstallConversionDataLoaded and onAppOpenAttribution.
But I don't get the onAppOpenAttribution when mounting the app for the first time even if I pressed a referal-link.
If I have the app running in background and pressing the referallink I get an onAppOpenAttribution callback. If I open the app with the link and then open it from the background I get the onAppOpenAttribution when opening from background.

Do you now if this is how it suppose to be?

@af-fess
Copy link
Collaborator

af-fess commented Oct 14, 2018

hey @katjastrof , are we talking about Android or iOS (+ OS version)? also please provide relevant code snippets of integration with AppsFlyer SDK.
Thank you,

@katjastrof
Copy link
Author

I'm using Android. I'm using the react-native-appsflyer 1.2.13 and the Android OS I've tested on is 7 and 8.

appsFlyer.onInstallConversionData(result => { if ( result.status == 'success' ) { console.log(result) } }) const options = { devKey: AF_DEV_KEY, isDebug: true, } appsFlyer.initSdk( options, result => { console.log(result) }, error => { console.error(error) } )

It's the appsFlyer.onInstallConversionData(result => {}) which gives a success callback when opening app. But the result type differs between being an onInstallConversionDataLoaded and onAppOpenAttribution. The problem I have is when I mounting the app from an referal link I get the type onInstallConversionDataLoaded . If I put the app in background and reopen it I get the onAppOpenAttribution. If I have the app running from start in background and open from the same referallink I get onAppOpenAttribution directly.

@bfinamore
Copy link

bfinamore commented Jan 2, 2019

I'm also experiencing this issue. When clicking a deeplink, onInstallDataLoaded event is consistently fired on launch/foreground, but onAppOpenAttribution only seems to be fired when the app is already running in the background prior to deeplink click, and NOT if the app is started up fresh. Also can confirm that backgrounding/foregrounding does then trigger onAppOpenAttribution in the fresh launch case. I have reproduced this behavior on both Android and iOS. Has anyone figured out a resolution or work-around for this?

Here's my implementation along with some log outputs for the various cases:

https://gist.github.com/bfinamore/a5e5c2f94861b7d49ee5f05f91223ae0

SDKs:
RN: 1.2.13
iOS: 4.8.8
Android: 4.8.18 (overrode build.gradle due to bugs in 4.8.14).

RN version: 0.55.4

Tested on:
iOS: iPhone 7 (12.1.2)
Android: Pixel 2 (8.1.0)

@af-fess
Copy link
Collaborator

af-fess commented Jan 23, 2019

Will be fixed in next week v1.4.0

@santiph
Copy link

santiph commented Feb 4, 2019

@af-fess is there any update on v1.4.0?

@af-fess
Copy link
Collaborator

af-fess commented Feb 5, 2019

@santiph we have a fix on the native side of SDK. So we are going to release Android 4.8.20 and next after - RN 1.4.0.

We already tested it with the beta version and everything works as expected.

Thank you,

@af-fess
Copy link
Collaborator

af-fess commented Feb 7, 2019

@katjastrof we tested a staging version, so far you can try this branch:

$ react-native install https://github.com/AppsFlyerSDK/react-native-appsflyer#dev/RD-16299/deeplink-oaoa-fix

For testing, we use dummy App.js:

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow
 */

import React, { Component } from "react";
import { Platform, AppState, StyleSheet, Text, Linking, View } from "react-native";
import appsFlyer from "react-native-appsflyer";

const options = {
  devKey: "WdpTVAcYwmxsaQ4WeTspmh",
  isDebug: true
};


async function initSdk(){
  try {
    var result = await appsFlyer.initSdk(options);
    console.log("Fess ::" + result);
   } catch (error) {
    console.log("Fess ::" + error);
}
}


export default class App extends Component {
  constructor() {
    super();
   
    this.state = {
      appState: AppState.currentState,
      initSdk: "init sdk",
      gcd: "",
      oaoa: ""
    };

  

    if (Platform.OS === "ios") {
      options.appId = "020190214";
    }

    this.onInstallConversionDataCanceller = appsFlyer.onInstallConversionData(
      data => {
        console.log(data);
        this.setState({ gcd: JSON.stringify(data) });
      }
    );

    this.onAppOpenAttributionCanceller = appsFlyer.onAppOpenAttribution(
      data => {
        console.log(data);
        this.setState({ oaoa: JSON.stringify(data) });
      }
    );


    initSdk();
  }

  _handleAppStateChange = (nextAppState) => {
    if (this.state.appState.match(/inactive|background/) && nextAppState === 'active') {    
      if (Platform.OS === 'ios') {
        appsFlyer.trackAppLaunch();
      }
    }
    
    if (this.state.appState.match(/active|foreground/) && nextAppState === 'background') {
      // if(this.onInstallConversionDataCanceller){
      //   this.onInstallConversionDataCanceller();
      //   console.log("unregister onInstallConversionDataCanceller");
      // } 
      // if(this.onAppOpenAttributionCanceller){
      //   this.onAppOpenAttributionCanceller();
      //   console.log("unregister onAppOpenAttributionCanceller");
      // }  
    }

    this.setState({appState: nextAppState});
  }

  componentWillUnmount() {
    AppState.removeEventListener('change', this._handleAppStateChange);
  }

  componentDidMount() {
    AppState.addEventListener('change', this._handleAppStateChange);

    Linking.getInitialURL(url => {
     console.log("componentDidMount" + url);
      //appsFlyer.sendDeepLinkData(url);      
    });
  }

  render() {
    return (
      <View style={styles.container}>
        <View style={{ flex: 0, flexDirection: "row" }}>
          <Text style={{ fontWeight: "bold" }}>init sdk: </Text>
          <Text>{this.state.initSdk}</Text>
        </View>
        <View style={{ flex: 0, flexDirection: "row" }}>
          <Text style={{ fontWeight: "bold" }}>gcd: {"\n"}</Text>
          <Text>{this.state.gcd}</Text>
        </View>
        <View style={{ flex: 0, flexDirection: "row" }}>
          <Text style={{ fontWeight: "bold" }}>OnAppOpenAttr: {"\n"}</Text>
          <Text>{this.state.oaoa}</Text>
        </View>
        {/* <Button title="Press for event" /> */}
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: "center",
    alignItems: "center",
    backgroundColor: "#F5FCFF"
  }
});

@af-fess
Copy link
Collaborator

af-fess commented Feb 18, 2019

@af-fess af-fess closed this as completed Feb 18, 2019
@aznj
Copy link

aznj commented Jul 2, 2019

This is happening on android sdk as well, and I believe they don't have fix for it yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants