Skip to content

Commit

Permalink
Proxy message event handle between push plugin and braze
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Vieira committed Aug 15, 2020
1 parent 87a8132 commit 0b62cb1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
12 changes: 7 additions & 5 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:amazon="http://schemas.android.com/apk/lib/com.amazon.device.ads"
xmlns:rim="http://www.blackberry.com/ns/widgets"
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:amazon="http://schemas.android.com/apk/lib/com.amazon.device.ads"
xmlns:rim="http://www.blackberry.com/ns/widgets"
id="phonegap-plugin-push" version="2.3.0">
<name>PushPlugin</name>
<description> This plugin allows your application to receive push notifications on Android, iOS and Windows devices. Android uses Firebase Cloud Messaging. iOS uses Apple APNS Notifications. Windows uses Microsoft WNS Notifications. </description>
Expand All @@ -16,6 +16,7 @@
<engine name="cordova-ios" version=">=4.5.0"/>
</engines>
<platform name="android">
<dependency id="cordova-plugin-appboy" url="https://github.com/qustodio/appboy-cordova-sdk#d888e3cb5af696464a79c09a05d502b77f3aeaa7" />
<config-file target="res/xml/config.xml" parent="/*">
<feature name="PushNotification">
<param name="android-package" value="com.adobe.phonegap.push.PushPlugin"/>
Expand All @@ -31,7 +32,7 @@
<activity android:name="com.adobe.phonegap.push.PushHandlerActivity" android:exported="true" android:permission="${applicationId}.permission.PushHandlerActivity"/>
<receiver android:name="com.adobe.phonegap.push.BackgroundActionButtonHandler"/>
<receiver android:name="com.adobe.phonegap.push.PushDismissedHandler"/>
<service android:name="com.adobe.phonegap.push.FCMService">
<service android:name="com.adobe.phonegap.push.ProxyFCMService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
Expand All @@ -49,6 +50,7 @@
<framework src="com.google.firebase:firebase-messaging:$FCM_VERSION"/>
<dependency id="cordova-support-google-services" version="~1.3.1"/>
<dependency id="phonegap-plugin-multidex" version="~1.0.0"/>
<source-file src="src/android/com/adobe/phonegap/push/ProxyFCMService.java" target-dir="src/com/adobe/phonegap/push/"/>
<source-file src="src/android/com/adobe/phonegap/push/FCMService.java" target-dir="src/com/adobe/phonegap/push/"/>
<source-file src="src/android/com/adobe/phonegap/push/PushConstants.java" target-dir="src/com/adobe/phonegap/push/"/>
<source-file src="src/android/com/adobe/phonegap/push/PushHandlerActivity.java" target-dir="src/com/adobe/phonegap/push/"/>
Expand Down
15 changes: 15 additions & 0 deletions src/android/com/adobe/phonegap/push/ProxyFCMService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.adobe.phonegap.push;

import com.appboy.AppboyFirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

public class ProxyFCMService extends FCMService {

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
boolean isForBraze = AppboyFirebaseMessagingService.handleBrazeRemoteMessage(this, remoteMessage);
if (!isForBraze) {
super.onMessageReceived(remoteMessage);
}
}
}

0 comments on commit 0b62cb1

Please sign in to comment.