앱이 열려있을 때만 내 앱이 알림을 받고있었습니다. 하지만 앱에 도달해야하는 알림이 필요합니다. 앱이 종료되었습니다. 어떻게 반응 네이티브 fcm을 사용하여 반응에서 이것을 할 수 있습니까? 내 코드React-native-fcm이 닫힌 앱에 대한 푸시 알림을 보내지 않습니다.
는 알림을 밀어하는 방법을 귀하의 문제가 그것
FCM.getInitialNotification().then(notif=>console.log(notif));
FCM.requestPermissions(); // for iOS
FCM.getFCMToken().then(token => {
console.log(token)
// store fcm token in your server
});
this.notificationListener = FCM.on(FCMEvent.Notification, async (notif) => {
// there are two parts of notif. notif.notification contains the notification payload, notif.data contains data payload
if(notif.local_notification){
//this is a local notification
return;
}
if(notif.opened_from_tray){
//app is open/resumed because user clicked banner
console.log('clicked');
return;
}
this.showLocalNotification(notif);
});
this.refreshTokenListener = FCM.on(FCMEvent.RefreshToken, (token) => {
console.log(token)
// fcm token may not be available on first load, catch it here
});
showLocalNotification(notif) {
FCM.presentLocalNotification({
title: notif.title,
body: notif.body,
priority: "high",
click_action: notif.click_action,
show_in_foreground: true,
local: true
});
}
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme">
<receiver android:name="com.evollu.react.fcm.FIRLocalMessagingPublisher"/>
<receiver android:enabled="true" android:exported="true" android:name="com.evollu.react.fcm.FIRSystemBootEventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON"/>
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<service android:name="com.evollu.react.fcm.MessagingService" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name="com.evollu.react.fcm.InstanceIdService" android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="fcm.ACTION.HELLO" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="XXXXXX"/>
</application>
'data' * * only * 페이로드 메시지를 사용 해본 적이 있습니까? –
데이터와 알림을 모두 보냈습니다. 나는 이것에 초보적이다. 나는 단지 내 requirment에 대한 반응 네이티브 - fcm을 사용하고 있습니다. –
죄송합니다. 혼란스러워. 앱이 전경/배경에있을 때 나만의 메시지를 처리하려고한다고 생각했습니다. 안드로이드의 동작은'data'와'notification'을 모두 가진 페이로드를 보낼 때, Notification Tray가 페이로드를 다룰 것입니다. 알림이 전혀 표시되지 않습니까? 여러 기기에서 테스트 해 보셨습니까? –