Skip to content

Commit

Permalink
getCurrentActivity fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wesfieldj committed May 7, 2019
1 parent 6321b44 commit 9a8f918
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 @@ -129,8 +130,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 @@ -239,7 +245,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 @@ -286,10 +296,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 9a8f918

Please sign in to comment.