log events for received and opened notifications ()

* log events for received and opened notifications
* app head: update to master
This commit is contained in:
Akinwale Ariwodola 2019-11-12 15:50:47 +01:00 committed by GitHub
parent 2699893581
commit 48543a48fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 4 deletions
src/main/java/io/lbry/browser

View file

@ -42,6 +42,7 @@ import com.facebook.react.modules.core.PermissionAwareActivity;
import com.facebook.react.modules.core.PermissionListener;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.react.ReactRootView;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
import com.rnfs.RNFSPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
@ -91,6 +92,8 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
private BroadcastReceiver downloadEventReceiver;
private FirebaseAnalytics firebaseAnalytics;
private ReactRootView mReactRootView;
private ReactInstanceManager mReactInstanceManager;
@ -149,6 +152,8 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
ServiceHelper.start(this, "", LbrynetService.class, "lbrynetservice");
}
checkNotificationOpenIntent(getIntent());
mReactRootView = new RNGestureHandlerEnabledRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
@ -174,6 +179,25 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
setContentView(mReactRootView);
}
private void checkNotificationOpenIntent(Intent intent) {
if (intent != null) {
String notificationName = intent.getStringExtra("notification_name");
if (notificationName != null) {
logNotificationOpen(notificationName);
}
}
}
private void logNotificationOpen(String name) {
if (firebaseAnalytics == null) {
firebaseAnalytics = FirebaseAnalytics.getInstance(this);
}
Bundle bundle = new Bundle();
bundle.putString("name", name);
firebaseAnalytics.logEvent("lbry_notification_open", bundle);
}
private void registerDownloadEventReceiver() {
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(DownloadManager.ACTION_DOWNLOAD_EVENT);
@ -534,6 +558,8 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
notificationManager.cancel(sourceNotificationId);
}
checkNotificationOpenIntent(intent);
}
super.onNewIntent(intent);