GCM canonical id

前端 未结 4 1129
暖寄归人
暖寄归人 2020-12-01 21:14

When having multiple regids for 1 device GCM returns the canonical id error:

{\"multicast_id\":xxxx,\"success\":2,\"failure\":0,\"canonical_ids\":1,\"results         


        
4条回答
  •  情话喂你
    2020-12-01 21:50

    query($q) ;
    if ($result1->num_rows > 0) {
    
    $response["users"] = array();
    
    while ($row = $result1->fetch_array(MYSQLI_BOTH)) {
        $user = array();
        $registrationIds = array($row[0]);
    
    
        $msg = array
        (
        'message'   => 'hieee',
        'title'     => 'Blood Bank',
        'subtitle'  => 'This is a subtitle. subtitle',
        'tickerText'    => 'Ticker text here...Ticker text here...Ticker text here',
        'vibrate'   => 1,
        'sound'     => 1,
        'largeIcon' => 'large_icon',
        'smallIcon' => 'small_icon'
        );
    
        $fields = array
        (
        'registration_ids'  => $registrationIds,
        'data'          => $msg
        );
    
        $headers = array
        (
        'Authorization: key=' . API_ACCESS_KEY,
        'Content-Type: application/json'
        );
    
        $ch = curl_init();
        curl_setopt( $ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/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, false );
        curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
        $result = curl_exec($ch );
        curl_close( $ch );
    
        echo $result;
        }
    } 
    else {
        $response["success"] = 0;
        $response["message"] = "No users found";
    }
    ?>
    

提交回复
热议问题