0

私のワンプラス3Tの最近のアプリからアプリをスワイプするとGoogle機能からPus通知を受け取ることができませんNexusエミュレータここで 特定のデバイスの最近のアプリからアプリがスワイプされたときにGoogle機能からの通知を受け取らないようにする

は、ここに私のGoogleの機能コード

//import firebase functions modules 
const functions = require('firebase-functions'); 
//import admin module 
const admin = require('firebase-admin'); 
admin.initializeApp(functions.config().firebase); 


// Listens for new messages added to messages/:pushId 
exports.pushNotification = functions.database.ref('notificationRequests/{pushId}').onWrite(event => { 

    console.log('Push notification event triggered'); 



    // Grab the current value of what was written to the Realtime Database. 
    var valueObject = event.data.val(); 



    // Create a notification 
    const payload = { 
     data: { 
      title:"New Reminder", 
      body: "You have a new Reminder" , 
      sound: "default" 
     }, 


    }; 

    //Create an options object that contains the time to live for the notification and the priority 
    const options = { 
     priority: "high", 
     timeToLive: 60 * 60 * 24 
    }; 


    return admin.messaging().sendToTopic(valueObject.receiverUID, payload, options) 
     .then(function(response){ 
      console.log("Succesfull",response); 
     }) 
     .catch(function(error){ 
      console.log("Error sending message",error); 
     }) 

}); 

ある

<service android:name=".FCMCallbackService"> 
      <intent-filter> 
       <action android:name="com.google.firebase.MESSAGING_EVENT" /> 
      </intent-filter> 
     </service> 

そして、ここでは私の依存関係しているマニフェストに

public class FCMCallbackService extends FirebaseMessagingService { 
    private static final String TAG = "FCMCallbackService"; 

    @Override 
    public void onMessageReceived(RemoteMessage remoteMessage) { 
     /*Log.d(TAG, "From:" + remoteMessage.getFrom()); 
     Log.d(TAG, "Message Body:" + remoteMessage.getNotification().getBody()); 
     //sendNotification(remoteMessage.getNotification()); 
     if (remoteMessage == null) 
      return; 
     if (remoteMessage.getNotification() != null) { 
      Log.i(TAG, "Notification Body: " + remoteMessage.getNotification().getBody()); 
     }*/ 
     // Check if message contains a data payload. 
     if (remoteMessage.getData().size() > 0) { 
      Log.i(TAG, "Data Payload: " + remoteMessage.getData().toString()); 
      String DataTitle = remoteMessage.getData().get("title"); 
      String body = remoteMessage.getData().get("body"); 
      Log.i(TAG, "Data Payload: " + DataTitle); 
      sendNotification(DataTitle,body); 

      // sendNotification(remoteMessage.getData().toString()); 
    }} 

    private void sendNotification(String title,String body) { 
     int color = getResources().getColor(R.color.colorPrimary); 
     Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 

     Intent intent = new Intent(this, MainActivity.class); 
     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
     PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 
       PendingIntent.FLAG_ONE_SHOT); 

     NotificationCompat.Builder builder = new NotificationCompat.Builder(this) 
       .setContentTitle(title) 
       .setContentText(body) 
       .setAutoCancel(true) 
       .setSmallIcon(R.drawable.common_google_signin_btn_icon_dark) 
       .setColor(color) 
       .setStyle(new NotificationCompat.BigTextStyle().bigText(body)) 
       .setSound(defaultSoundUri) 
       .setContentIntent(pendingIntent); 

     NotificationManager notificationManager = (NotificationManager) 
       getSystemService(Context.NOTIFICATION_SERVICE); 
     notificationManager.notify(0, builder.build()); 
    } 
} 

サービスをOnMessageReceived whhich機能、FCMコールbackServiceコードです何らかの理由でFIrebase Messagingの古いバージョンを使用していますトンのエラーは、「解決できません..」私は10.4.1を使用している場合。(はい、私は更新されているGoogleがサービスやリポジトリをプレイ)

compile 'com.google.firebase:firebase-auth:9.0.2' 
compile 'com.android.support:design:25.1.0' 
compile 'com.google.firebase:firebase-database:9.0.2' 
testCompile 'junit:junit:4.12' 
compile 'com.android.support:gridlayout-v7:25.1.0' 
compile 'com.android.support:cardview-v7:25.1.0' 
compile 'com.google.firebase:firebase-messaging:9.0.1' 

compile 'com.android.support:recyclerview-v7:25.1.0' 
compile 'com.firebaseui:firebase-ui-database:0.4.1' 
+0

[Androidタスクがマルチタスクトレイからアプリケーションを停止したときにAndroidベースのアプリケーションを受信できません](https://stackoverflow.com/questions/) 39504805/android-app-not-receiving-firebase-notification-app-is-multi-tから停止した場合) –

答えて

0

あなたは1プラス設定でアプリケーションをホワイトリストに登録する必要があります。中国のメーカーは、アプリがバックグラウンドで実行されないようにしています。あなたはXiaomi、Vivo、gionee、Oppoなどの類似の状況に直面するでしょう。

関連する問題