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

Commit

Permalink
Adding ability to (un/)subscribe to topics at firebase #262 - iOS imp…
Browse files Browse the repository at this point in the history
…lementation
  • Loading branch information
EddyVerbruggen committed Jan 17, 2017
1 parent 6a2521b commit 0f09d14
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
9 changes: 5 additions & 4 deletions firebase.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
Expand All @@ -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");
Expand All @@ -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) {
Expand Down
36 changes: 36 additions & 0 deletions firebase.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0f09d14

Please sign in to comment.