This repository was archived by the owner on Apr 4, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -1491,6 +1491,51 @@ firebase.deleteFile = function (arg) {
14911491 } ) ;
14921492} ;
14931493
1494+ firebase . subscribeToTopic = function ( topicName ) {
1495+ return new Promise ( function ( resolve , reject ) {
1496+ try {
1497+
1498+ if ( typeof ( com . google . firebase . messaging ) === "undefined" ) {
1499+ reject ( "Uncomment firebase-messaging in the plugin's include.gradle first" ) ;
1500+ return ;
1501+ }
1502+
1503+ if ( firebase . instance === null ) {
1504+ reject ( "Can be run only after init" ) ;
1505+ return ;
1506+ }
1507+
1508+ com . google . firebase . messaging . FirebaseMessaging . getInstance ( ) . subscribeToTopic ( topicName ) ;
1509+
1510+ } catch ( ex ) {
1511+ console . log ( "Error in firebase.subscribeToTopic: " + ex ) ;
1512+ reject ( ex ) ;
1513+ }
1514+ } ) ;
1515+ } ;
1516+
1517+ firebase . unsubscribeFromTopic = function ( topicName ) {
1518+ return new Promise ( function ( resolve , reject ) {
1519+ try {
1520+
1521+ if ( typeof ( com . google . firebase . messaging ) === "undefined" ) {
1522+ reject ( "Uncomment firebase-messaging in the plugin's include.gradle first" ) ;
1523+ return ;
1524+ }
1525+
1526+ if ( firebase . instance === null ) {
1527+ reject ( "Can be run only after init" ) ;
1528+ return ;
1529+ }
1530+
1531+ com . google . firebase . messaging . FirebaseMessaging . getInstance ( ) . unsubscribeFromTopic ( topicName ) ;
1532+
1533+ } catch ( ex ) {
1534+ console . log ( "Error in firebase.unsubscribeFromTopic: " + ex ) ;
1535+ reject ( ex ) ;
1536+ }
1537+ } ) ;
1538+ }
14941539/*
14951540firebase.sendCrashLog = function (arg) {
14961541 return new Promise(function (resolve, reject) {
Original file line number Diff line number Diff line change @@ -569,5 +569,8 @@ export function getDownloadUrl(options: GetDownloadUrlOptions): Promise<string>;
569569
570570export function deleteFile ( options : DeleteFileOptions ) : Promise < any > ;
571571
572+ export function subscribeToTopic ( topicName ) : Promise < any > ;
573+
574+ export function unsubscribeFromTopic ( topicName ) : Promise < any > ;
572575// crash logging
573576// export function sendCrashLog(options: SendCrashLogOptions): Promise<any>;
You can’t perform that action at this time.
0 commit comments