Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
Added partial Android FCM support (#975)
Browse files Browse the repository at this point in the history
* Modified plugin.xml to include FCM changes

* Plugin.xml changes for FCM

* Java changes for FCM

* Increased plugin version to 2.0.0

* Increased plugin version in package.json

* Added topic subscription/unsubscription

* Removed some empty lines
  • Loading branch information
jcesarmobile authored and macdonst committed May 4, 2017
1 parent 2535a18 commit 24f0a77
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
14 changes: 10 additions & 4 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?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" id="phonegap-plugin-push" version="2.0.0-rc2">
<?xml version="1.0" encoding="UTF-8"?>
<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.0.0">

<name>PushPlugin</name>
<description>
This plugin allows your application to receive push notifications on Android, iOS and Windows devices.
Expand Down Expand Up @@ -44,7 +50,7 @@
</service>
</config-file>
<framework src="com.android.support:support-v13:25.1.0"/>
<framework src="me.leolin:ShortcutBadger:1.1.11@aar"/>
<framework src="me.leolin:ShortcutBadger:1.1.14@aar"/>
<framework src="com.google.firebase:firebase-messaging:9.8.0"/>
<framework src="push.gradle" custom="true" type="gradleReference"/>
<source-file src="src/android/com/adobe/phonegap/push/FCMService.java" target-dir="src/com/adobe/phonegap/push/"/>
Expand Down Expand Up @@ -95,4 +101,4 @@
<preference name="WindowsToastCapable" value="true"/>
</config-file>
</platform>
</plugin>
</plugin>
10 changes: 8 additions & 2 deletions src/android/com/adobe/phonegap/push/PushPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,10 @@ private void subscribeToTopics(JSONArray topics, String registrationToken) {
String topic = null;
for (int i=0; i<topics.length(); i++) {
topic = topics.optString(i, null);
subscribeToTopic(topic, registrationToken);
if (topic != null) {
Log.d(LOG_TAG, "Subscribing to topic: " + topic);
FirebaseMessaging.getInstance().subscribeToTopic(topic);
}
}
}
}
Expand All @@ -363,7 +366,10 @@ private void unsubscribeFromTopics(JSONArray topics, String registrationToken) {
String topic = null;
for (int i=0; i<topics.length(); i++) {
topic = topics.optString(i, null);
unsubscribeFromTopic(topic, registrationToken);
if (topic != null) {
Log.d(LOG_TAG, "Unsubscribing to topic: " + topic);
FirebaseMessaging.getInstance().unsubscribeFromTopic(topic);
}
}
}
}
Expand Down

0 comments on commit 24f0a77

Please sign in to comment.