0

My code is here Please see carefully IOs gcm not working in background only working in foreground php script

     $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;

My Ios developer said to me its only working in foreground not working in background.This is properly working in android Please help fast Thanks in advance

1 Answers1

0

You need to put notification parameter into your message. This way, GCM will deliver your message over APNS. Or, use content_available.

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

TheWonderBird
  • 663
  • 3
  • 11