I am using following code to send parse.com push notification form my PHP form using REST API.
$APPLICATION_ID = 'Applicatio_id_here';
$REST_API_KEY = 'Rest_api_key_here';
$data = [
'where' => ['channels' => ''],
'expiry' => time() + 1000,
'data' => [
'alert' => $notification,
],
];
$_data = json_encode($data);
$headers = [
'X-Parse-Application-Id: ' . $APPLICATION_ID,
'X-Parse-REST-API-Key: ' . $REST_API_KEY,
'Content-Type: application/json',
'Content-Length: ' . strlen($_data),
];
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_exec($curl);
My parse.com account is setup for both Android and iOS push notification. And I am able to get notification on Android device successfully. But the problem is with the iPhone. I am not getting any notification on iPhone device.
But iPhone device is receiving notification successfully, if I send the notification from the parse.com admin (Send a push).
One more thing to mention, in parse.com admin, I could see Channel = ["global"] for iOS devices but [""] blank for Android device. So I think there might be some problem in my PHP code.
If it is not possible to send same message with this code, please help me with some working code. I need this as my app for both devices are already online.
Try to change your "$data" to this one:
$data = [ 'where' => ['channels' => 'global'] OR ['channels' => ''], 'expiry' => time()
Another option :
$data = ['where' => 'channels' => 'global' OR 'channels' => '', 'expiry' => time()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.