2017-10-25 5 views
0

Ich verwende react-native-firebase für FCM, wenn App im Hintergrund Benachrichtigung Popup richtig angezeigt wird. Wenn die App im Vordergrund ausgeführt wird, wird keine Benachrichtigung angezeigt. Derselbe Code funktioniert für Android. Verwenden des unteren CodesNative iOS reagieren, Vordergrundbenachrichtigung funktioniert nicht

this.firebase.messaging().createLocalNotification({ 

     title: 'Messenger',  
     body: "message", 
     icon: 'ic_launcher', 
     id: new Date().getTime()+"", 
     action: action, 
     screen: screen, 
     local_notification: true, 
     show_in_foreground: true, 
     _notificationType: 'local_notification', 
     opened_from_tray: false 

    }); 

Antwort

0

Ab dem read-native-fcm-Modul muss die Nutzlast folgende Schlüsselwertpaare enthalten.

{ 
     id: "UNIQ_ID_STRING",        // (optional for instant notification) 
     title: "My Notification Title",      // as FCM payload 
     body: "My Notification Message",     // as FCM payload (required) 
     sound: "default",         // as FCM payload 
     priority: "high",         // as FCM payload 
     click_action: "ACTION",        // as FCM payload 
     badge: 10,           // as FCM payload IOS only, set 0 to clear badges 
     number: 10,           // Android only 
     ticker: "My Notification Ticker",     // Android only 
     auto_cancel: true,         // Android only (default true) 
     large_icon: "ic_launcher",       // Android only 
     icon: "ic_launcher",        // as FCM payload, you can relace this with custom icon you put in mipmap 
     big_text: "Show when notification is expanded",  // Android only 
     sub_text: "This is a subText",      // Android only 
     color: "red",          // Android only 
     vibrate: 300,          // Android only default: 300, no vibration if you pass 0 
     group: "group",          // Android only 
     picture: "https://google.png",      // Android only bigPicture style 
     ongoing: true,          // Android only 
     my_custom_data:'my_custom_field_value',    // extra data you want to throw 
     lights: true,          // Android only, LED blinking (default false) 
     show_in_foreground         // notification when app is in foreground (local & remote) 
    } 

„show_in_foreground“ muß zur Verfügung gestellt werden, um lokale Anmeldung im Vordergrund anzuzeigen, wenn Ihre Anwendung ausgeführt wird.

+0

"show_in_foreground" nur auf "True" gesetzt –

+0

Ja, es sollte auf "True" gesetzt sein. – Prince

+0

seine nur auf True gesetzt, aber keine Benachrichtigung im Vordergrund –

Verwandte Themen