0

パーズサーバーでプッシュ通知を受信しませんでした。「SENT」と表示されているが、配信されていないダッシュボードからのみ試しました。ここでFCMでパーズサーバープッシュ通知を受信しませんでした。

は私のindex.js構成です:

push: { 
android: { 
    senderId: '<my FCM sender Id>', 
    apiKey: '<my FCM API Key>' 
    } 

は、ここに私のManifest.xmlです:ここで

<uses-permission android:name="android.permission.WAKE_LOCK" /> 
<uses-permission android:name="android.permission.VIBRATE" /> 
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> 
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> 
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 


<permission 
    android:name="com.example.asus.shopper.permission.C2D_MESSAGE" 
    android:protectionLevel="signature" /> 

<uses-permission android:name="com.example.asus.shopper.permission.C2D_MESSAGE" /> 

<meta-data 
     android:name="com.parse.push.gcm_sender_id" 
     android:value="id:1196432287**" /> 

    <service android:name="com.parse.PushService" /> 



    <receiver 
     android:name="com.parse.GcmBroadcastReceiver" 
     android:permission="com.google.android.c2dm.permission.SEND"> 
     <intent-filter> 
      <action android:name="com.google.android.c2dm.intent.RECEIVE" /> 
      <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> 

      <category android:name="com.example.asus.shopper" /> 
     </intent-filter> 
    </receiver> 
    <receiver 
     android:name="com.parse.ParsePushBroadcastReceiver" 
     android:exported="false"> 
     <intent-filter> 
      <action android:name="com.parse.push.intent.RECEIVE" /> 
      <action android:name="com.parse.push.intent.OPEN" /> 
      <action android:name="com.parse.push.intent.DELETE" /> 
     </intent-filter> 
    </receiver> 
     //here to test if notifications from firebase console is working and it's working 
    <service android:name=".network.MyFirebaseMessagingService"> 
     <intent-filter> 
      <action android:name="com.google.firebase.MESSAGING_EVENT" /> 
     </intent-filter> 
    </service> 
    <service android:name=".network.FirebaseIDService"> 
     <intent-filter> 
      <action android:name="com.google.firebase.INSTANCE_ID_EVENT" /> 
     </intent-filter> 
    </service> 

    <meta-data android:name="com.parse.push.notification_icon" 
     android:resource="@mipmap/ic_launcher"/> 

    <receiver 
     android:name=".network.CustomPushReceiver" 
     android:enabled="true" 
     android:exported="false"> 
     <intent-filter> 
      <action android:name="android.intent.action.BOOT_COMPLETED" /> 
      <action android:name="android.intent.action.USER_PRESENT" /> 
      <action android:name="com.parse.push.intent.RECEIVE" /> 
      <action android:name="com.parse.push.intent.DELETE" /> 
      <action android:name="com.parse.push.intent.OPEN" /> 
     </intent-filter> 
    </receiver> 

は私のカスタム受信者のソースコード

public class CustomPushReceiver extends ParsePushBroadcastReceiver { 
private final String TAG = CustomPushReceiver.class.getSimpleName(); 

private NotificationUtils notificationUtils; 

private Intent parseIntent; 

public CustomPushReceiver() { 
    super(); 
} 

@Override 
protected void onPushReceive(Context context, Intent intent) { 
    super.onPushReceive(context, intent); 

    if (intent == null){ 
     Log.d("CustomPushReceiver","null"); 
    } 

    try { 
     JSONObject json = new JSONObject(intent.getExtras().getString("com.parse.Data")); 

     Log.e(TAG, "Push received: " + json); 

     parseIntent = intent; 

     parsePushJson(context, json); 

    } catch (JSONException e) { 
     Log.e(TAG, "Push message json exception: " + e.getMessage()); 
    } 
} 

@Override 
protected void onPushDismiss(Context context, Intent intent) { 
    super.onPushDismiss(context, intent); 
} 

@Override 
protected void onPushOpen(Context context, Intent intent) { 
    super.onPushOpen(context, intent); 
} 

/** 
* Parses the push notification json 
* 
* @param context 
* @param json 
*/ 
private void parsePushJson(Context context, JSONObject json) { 
    try { 
     boolean isBackground = json.getBoolean("is_background"); 
     JSONObject data = json.getJSONObject("data"); 
     String title = data.getString("title"); 
     String message = data.getString("message"); 

     if (!isBackground) { 
      Intent resultIntent = new Intent(context, DashboardActivity.class); 
      showNotificationMessage(context, title, message, resultIntent); 
     } 

    } catch (JSONException e) { 
     Log.e(TAG, "Push message json exception: " + e.getMessage()); 
    } 
} 


/** 
* Shows the notification message in the notification bar 
* If the app is in background, launches the app 
* 
* @param context 
* @param title 
* @param message 
* @param intent 
*/ 
private void showNotificationMessage(Context context, String title, String message, Intent intent) { 

    notificationUtils = new NotificationUtils(context); 

    intent.putExtras(parseIntent.getExtras()); 

    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); 

    notificationUtils.showNotificationMessage(title, message, intent); 
} 

}

です最後に、t彼は私がカスタムレシーバと呼ぶ場所です.DashboardActivity:

@Override 
protected void onNewIntent(Intent intent) { 
    super.onNewIntent(intent); 
    String message = intent.getStringExtra("message"); 

    Log.d("MESSAGE",message); 
} 

私はものが恋しいのか教えてください。私は、パースのドキュメントと他の開発者の答えは、stackoverflowで不足することなく続きました。

PS:私が使用している最小SDKのバージョンは、私は同じ問題を抱えていた19

答えて

0

です。

まず、パッシブサーバーをプッシュ通知用に直接使用しようとしないでください。あなたはindex.jsファイルをつぶすべきではありません。 FCMのファイアベース文書に固執するだけです。

第2に、プッシュ通知のFirebaseドキュメントに従ってください。

第3に、準備ができたら、必要に応じてParse-ServerにFirebaseプッシュ通知トークンを保存します。

これは、FCMが無料であるため、長期的にお金を節約します。また、FC Mwith Parse-Serverを押すのを妨げると、それはあなたのdynosを使い果たします。

関連する問題