diff --git a/firebase.android.js b/firebase.android.js index 901f0e4a..e84bba2b 100755 --- a/firebase.android.js +++ b/firebase.android.js @@ -1493,7 +1493,7 @@ firebase.deleteFile = function (arg) { firebase.subscribeToTopic = function(topicName){ return new Promise(function (resolve, reject) { - try{ + try { if (typeof(com.google.firebase.messaging) === "undefined") { reject("Uncomment firebase-messaging in the plugin's include.gradle first"); @@ -1506,7 +1506,7 @@ firebase.subscribeToTopic = function(topicName){ } com.google.firebase.messaging.FirebaseMessaging.getInstance().subscribeToTopic(topicName); - + resolve(); } catch(ex){ console.log("Error in firebase.subscribeToTopic: " + ex); reject(ex); @@ -1516,7 +1516,7 @@ firebase.subscribeToTopic = function(topicName){ firebase.unsubscribeFromTopic = function(topicName){ return new Promise(function (resolve, reject) { - try{ + try { if (typeof(com.google.firebase.messaging) === "undefined") { reject("Uncomment firebase-messaging in the plugin's include.gradle first"); @@ -1529,13 +1529,14 @@ firebase.unsubscribeFromTopic = function(topicName){ } com.google.firebase.messaging.FirebaseMessaging.getInstance().unsubscribeFromTopic(topicName); - + resolve(); } catch(ex){ console.log("Error in firebase.unsubscribeFromTopic: " + ex); reject(ex); } }); } + /* firebase.sendCrashLog = function (arg) { return new Promise(function (resolve, reject) { diff --git a/firebase.ios.js b/firebase.ios.js index ca87843a..0e99762e 100755 --- a/firebase.ios.js +++ b/firebase.ios.js @@ -1569,6 +1569,42 @@ firebase.deleteFile = function (arg) { }); }; +firebase.subscribeToTopic = function(topicName){ + return new Promise(function (resolve, reject) { + try { + + if (typeof(FIRMessaging) === "undefined") { + reject("Enable FIRMessaging in Podfile first"); + return; + } + + FIRMessaging.messaging().subscribeToTopic(topicName); + resolve(); + } catch(ex){ + console.log("Error in firebase.subscribeToTopic: " + ex); + reject(ex); + } + }); +}; + +firebase.unsubscribeFromTopic = function(topicName){ + return new Promise(function (resolve, reject) { + try { + + if (typeof(FIRMessaging) === "undefined") { + reject("Enable FIRMessaging in Podfile first"); + return; + } + + FIRMessaging.messaging().unsubscribeFromTopic(topicName); + resolve(); + } catch(ex){ + console.log("Error in firebase.unsubscribeFromTopic: " + ex); + reject(ex); + } + }); +} + /* firebase.sendCrashLog = function (arg) { return new Promise(function (resolve, reject) {