Android Firebase通知作为GCM收到

时间:2018-05-17 14:54:00

标签: android firebase push-notification

我在我的android项目中使用android firebase通知并且它工作正常,除了一些设备,没有收到firebase通知,而是我在Logcat中得到以下内容:

  

05-17 17:38:22.292 27292-27292 / com.example.myapp D / ActivityThread:BDC-Calling onReceive:intent = Intent {act = com.google.android.c2dm.intent.RECEIVE flg = 0x10 pkg = com.example.myapp cmp = com.example.myapp / com.google.firebase.iid.FirebaseInstanceIdReceiver(has extras)},ordered = true,receiver = com.google.firebase.iid.FirebaseInstanceIdReceiver@422443a8

     

05-17 17:38:22.295 27292-27292 / com.example.myapp E / FirebaseInstanceId:解析目标意图服务时出错,跳过了类名强制执行。已解决的服务是:tv.peel.app/com.peel.receiver.FCMService

     

05-17 17:38:22.411 27292-27292 / com.example.myapp D / ActivityThread:处理的BDC-RECEIVER:0 / ReceiverData {intent = Intent {act = com.google.android.c2dm.intent.RECEIVE flg = 0x10 pkg = com.example.myapp(有附加内容)} packageName = com.example.myapp resultCode = -1 resultData = null resultExtras = null}

com.google.android.c2dm.intent.RECEIVE用于GCM,我之前从未在我的应用中使用过! P.S:我使用php curl通过firebase通知发送数据有效负载,除上述情况外它正在工作。

$fields = array
(
    'registration_ids'  => $registrationIds,
    'data'          => $data
);
$headers = array
(
    'Authorization: key=' . API_ACCESS_KEY,
    'Content-Type: application/json'
);
$ch = curl_init(); 
curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, true );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
curl_close( $ch );
echo $result;

,$ result是:

  

{     “multicast_id”:5419052642417855073,     “成功”:1,     “失败”:0,     “canonical_ids”:0,     “结果”:[       {         “message_id”:“0:1526567349119146%bc732c83f9fd7ecd”       }     ]   }

编辑: 清单中的服务:

<service android:name=".firebase.MyFirebaseMessagingService" android:exported="false">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
</service>
<service android:name=".firebase.MyFirebaseInstanceIDService" android:exported="false">
    <intent-filter>
        <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
    </intent-filter>
</service>

0 个答案:

没有答案