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

Commit

Permalink
Merge pull request #262 from markosko/master
Browse files Browse the repository at this point in the history
Adding ability to (un/)subscribe to topics at firebase
  • Loading branch information
EddyVerbruggen authored Jan 17, 2017
2 parents 1a69df3 + 747a5ee commit 6a2521b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
45 changes: 45 additions & 0 deletions firebase.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,51 @@ firebase.deleteFile = function (arg) {
});
};

firebase.subscribeToTopic = function(topicName){
return new Promise(function (resolve, reject) {
try{

if (typeof(com.google.firebase.messaging) === "undefined") {
reject("Uncomment firebase-messaging in the plugin's include.gradle first");
return;
}

if (firebase.instance === null) {
reject("Can be run only after init");
return;
}

com.google.firebase.messaging.FirebaseMessaging.getInstance().subscribeToTopic(topicName);

} catch(ex){
console.log("Error in firebase.subscribeToTopic: " + ex);
reject(ex);
}
});
};

firebase.unsubscribeFromTopic = function(topicName){
return new Promise(function (resolve, reject) {
try{

if (typeof(com.google.firebase.messaging) === "undefined") {
reject("Uncomment firebase-messaging in the plugin's include.gradle first");
return;
}

if (firebase.instance === null) {
reject("Can be run only after init");
return;
}

com.google.firebase.messaging.FirebaseMessaging.getInstance().unsubscribeFromTopic(topicName);

} catch(ex){
console.log("Error in firebase.unsubscribeFromTopic: " + ex);
reject(ex);
}
});
}
/*
firebase.sendCrashLog = function (arg) {
return new Promise(function (resolve, reject) {
Expand Down
3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,5 +569,8 @@ export function getDownloadUrl(options: GetDownloadUrlOptions): Promise<string>;

export function deleteFile(options: DeleteFileOptions): Promise<any>;

export function subscribeToTopic(topicName): Promise<any>;

export function unsubscribeFromTopic(topicName): Promise<any>;
// crash logging
// export function sendCrashLog(options: SendCrashLogOptions): Promise<any>;

0 comments on commit 6a2521b

Please sign in to comment.