Skip to content

Commit

Permalink
Merge pull request #84 from AppsFlyerSDK/dev/getCurrentActivity-fix
Browse files Browse the repository at this point in the history
getCurrentActivity fix
  • Loading branch information
af-fess authored May 19, 2019
2 parents 789dd38 + 9a8f918 commit 64332f0
Showing 1 changed file with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import android.app.Application;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
Expand Down Expand Up @@ -130,8 +131,13 @@ private String callSdkInternal(ReadableMap _options) {
(isConversionData == true) ? registerConversionListener() : null,
application.getApplicationContext());

Intent intent = null;
Activity currentActivity = getCurrentActivity();

if (currentActivity != null) {
intent = currentActivity.getIntent();
}

Intent intent = this.getCurrentActivity().getIntent();
//Generally we already do this validation into the SDK, anyways, we want to show it to clients
if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) {
AppsFlyerLib.getInstance().setPluginDeepLinkData(intent);
Expand Down Expand Up @@ -240,7 +246,11 @@ private String trackEventInternal(final String eventName, ReadableMap eventData)
data = new HashMap<>();
}

AppsFlyerLib.getInstance().trackEvent(getCurrentActivity().getBaseContext(), eventName, data);
Activity currentActivity = getCurrentActivity();

if (currentActivity != null) {
AppsFlyerLib.getInstance().trackEvent(currentActivity.getBaseContext(), eventName, data);
}

return null;
}
Expand Down Expand Up @@ -287,10 +297,16 @@ public void trackEventWithPromise(
@ReactMethod
public void sendDeepLinkData(String url) {
if (url != null) {
Intent intent = getCurrentActivity().getIntent();
Uri uri = Uri.parse(url);
intent.setData(uri);
AppsFlyerLib.getInstance().sendDeepLinkData(this.getCurrentActivity());

Intent intent = null;
Activity currentActivity = getCurrentActivity();

if (currentActivity != null) {
intent = currentActivity.getIntent();
Uri uri = Uri.parse(url);
intent.setData(uri);
AppsFlyerLib.getInstance().sendDeepLinkData(this.getCurrentActivity());
}
}
}

Expand Down

0 comments on commit 64332f0

Please sign in to comment.