Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/254.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php中发送推送通知时注册无效_Php_Codeigniter_Push Notification_Apple Push Notifications - Fatal编程技术网

在php中发送推送通知时注册无效

在php中发送推送通知时注册无效,php,codeigniter,push-notification,apple-push-notifications,Php,Codeigniter,Push Notification,Apple Push Notifications,我正在关注这一点。但是得到了一个错误invalidregistrationid 谷歌搜索了一下,但什么也没找到。 我还发现了一些相关的问题,这些问题已经在StackOverflow上得到了解答。但没有解决办法。 下面是我访问的解决方案链接 任何帮助都将不胜感激。 谢谢我正在实现您的代码 使用在设备(ios/android)中生成的firebase注册令牌 而不是设备令牌。 'registration\u id'=>(数组)$token, 希望对您有所帮助hi@Dharman我没有使用pem文

我正在关注这一点。但是得到了一个错误
invalidregistrationid

谷歌搜索了一下,但什么也没找到。 我还发现了一些相关的问题,这些问题已经在StackOverflow上得到了解答。但没有解决办法。 下面是我访问的解决方案链接

  • 任何帮助都将不胜感激。
    谢谢

    我正在实现您的代码

    使用在设备(ios/android)中生成的
    firebase注册令牌
    而不是设备令牌。
    
    'registration\u id'=>(数组)$token,


    希望对您有所帮助

    hi@Dharman我没有使用pem文件我使用firebase访问令牌进行推送通知我不是firebase专家,但无论如何我知道您不应该禁用这两个选项。完整阅读链接文章,也许它也能帮助您正确设置firebase上的cUrl。@Dharman谢谢您的建议,但我的错误已经解决了
    class abc{
      function send_android_notification($registration_ids="2fa86bbc8bc4aee204255a0d84461c000a26442312d0a9b1df1664d461fd3b7d") {
          $message = array('title' => 'CodeCastra', 'body' => "hi huye" ,'sound'=>'Default','image'=>'Notification Image' );
          define("GOOGLE_API_KEY", "AIzaSyDDvpPcWfOTVkkvA-yQg4yTYzIuh0MNIRw"); //legacy server key
          $fields = array(
              'registration_ids' => (array)$registration_ids,
              'notification' => $message, //note: body & title fileds must be specified for the message or your only get just the vibration but the notification
          );
          $headers = array(
              'Authorization: key=' . GOOGLE_API_KEY, //  FIREBASE_API_KEY_FOR_ANDROID_NOTIFICATION
              'Content-Type: application/json'
          );
          //Open connection
          $ch = curl_init();
          //Set the url, number of POST vars, POST data
          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_SSL_VERIFYHOST, 0);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          // Disabling SSL Certificate support temporarly
          curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
          curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
          //echo json_encode($fields);
          //print_r($headers);
          //exit;
          //Execute post
          $result = curl_exec($ch);
          if ($result === false) {
              die('Curl failed:' . curl_errno($ch));
          }
          // Close connection
          curl_close($ch);
          return $result;
      }
    
    }
    
    print_r((new abc)->send_android_notification());
    die;
    
    {"multicast_id":4707836736661373968,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}