Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70752

Notification not working when app is closed

$
0
0

@safaAlshaarri wrote:

hi every one i have an app where i need to send notification it’s working very fine on emulator but on device it’s not working … it works when the app is opened but when it’s closed it don’t show
here is the used code
i used FMC provider

async getToken() {

    let token;
  
    if (this.platform.is('android')) {
      token = await this.firebaseNative.getToken()
    } 
  
    if (this.platform.is('ios')) {
      token = await this.firebaseNative.getToken();
      await this.firebaseNative.grantPermission();
    } 
    
    return this.saveTokenToFirestore(token)
  }
  // Save the token to firestore
  private saveTokenToFirestore(token) {
    if (!token) return;
  
    const devicesRef = this.afs.collection('devices')
  
    const docData = { 
      token,
      userId: 'user:'+this.deviceID,
    }
  
    return devicesRef.doc(token).set(docData)
  }

  // Listen to incoming FCM messages
  listenToNotifications() {
    return this.firebaseNative.onNotificationOpen()
  }

firebase
@ionic-native/firebase”: “^4.0.0”,
“angularfire2”: “^5.0.0-rc.11”,
@ionic-native/background-mode”: “^4.20.0”,
please help me
thank u

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70752

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>