启用FCM推送通知以将应用打开到前台

时间:2018-10-02 11:50:28

标签: firebase ionic-framework ionic3 firebase-cloud-messaging

我想在基于fcm的向前台推送通知时打开ionic 3应用程序

payload = {
  notification: {
    title: 'New ' + event.data().type,
    body: event.data().body ? event.data().body : '' + comment,
    icon: 'https://firebasestorage.googleapis.com/v0/b/naturehu-bf51e.appspot.com/o/fevicon%2Ficon.png?alt=media&token=d0dbfda7-710a-4bbb-97c9-62418ce6c530',
    sound: 'default',
    click_action:"FCM_PLUGIN_ACTIVITY"
  }
}
options = {
  priority: "high",
  timeToLive: 60 * 60 * 24
};

在打开应用但将其发送回后台的情况下,帮助将应用打开到前台

1 个答案:

答案 0 :(得分:0)

您的问题是信息较少。无论如何,请尝试在private FirebaseAuth mAuth; mAuth = FirebaseAuth.getInstance(); mAuth.createUserWithEmailAndPassword(email, password) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { // Sign in success, update UI with the signed-in user's information Log.d(TAG, "createUserWithEmail:success"); FirebaseUser user = mAuth.getCurrentUser(); updateUI(user); } else { // If sign in fails, display a message to the user. Log.w(TAG, "createUserWithEmail:failure", task.getException()); Toast.makeText(EmailPasswordActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); updateUI(null); } // ... } }); 以下。

payload