【问题标题】:IOs gcm not working in background only working in foreground php scriptIOs gcm 不能在后台工作,只能在前台 php 脚本中工作
【发布时间】:2015-08-24 12:41:09
【问题描述】:

我的代码在这里 请仔细看 IOs gcm 不能在后台工作,只能在前台 php 脚本中工作

     $data   = array('message' =>$msg,
    'contentTitle'      => $msg,
     "tickerText" => "some ticker text", 
     "contentTitle" => "some content title",
     "contentText" => "some content description text",
     "sound"=> "default",
     "vibrate" => "false",
     "otherCustomData" => "some value" 

                        );
        $fields = array(
            'registration_ids' => $registrationIDs,
            'data' =>  array("message" => $data),
            'content_available' => true
        );
            //have to change
            $headers = array(
            'Authorization: key=IDSSSSSSS',
            'Content-Type: application/json'
        );
        }


        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        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));

        // Execute post
        $result = curl_exec($ch);
        // print_r($result);
        if ($result === FALSE)
        {
            die('Curl failed: ' . curl_error($ch));
        }

        // Close connection
        curl_close($ch);
        echo $result;

我的 Ios 开发人员对我说它只能在前台工作而不是在后台工作。这在 android 中正常工作 请速帮忙 提前致谢

【问题讨论】:

    标签: php android ios google-cloud-messaging


    【解决方案1】:

    您需要将notification 参数放入您的消息中。这样,GCM 将通过 APNS 传递您的消息。或者,使用content_available

    https://developers.google.com/cloud-messaging/http-server-ref#notification-payload-support

    【讨论】:

      猜你喜欢
      • 2021-05-22
      • 2015-09-15
      • 2019-01-22
      • 2018-01-13
      • 2019-09-11
      • 1970-01-01
      • 1970-01-01
      • 2013-05-04
      • 2012-09-03
      相关资源
      最近更新 更多