0

I'm working on and IOS App that will send push notifications with FCM, i've configured everything right on the FCM Console and tested sending a message from the console to the device and it worked. Now i'm using the below script and the message is not able to push to the phone. When i send i get this message

{"multicast_id":7893466200486146313,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1506525095628728%b54fead7f9fd7ecd"}]}

Below is my script

// Replace with the real server API key from Google APIs
$apiKey = "-------";
// Replace with the real client registration IDs
$registrationIDs = array('00000');
// Message to be sent
$message = "New Message from GWCL";
$url = 'https://fcm.googleapis.com/fcm/send';
$fields = array(
    'registration_ids' => $registrationIDs,
    'data' => array( 'message' => $message,'title' => "New Message",'notId'=>''.time(), 'complain_id'=>'90','push'=>'reply','priority'=>'high'),
);

$headers = array(
    'Authorization: key=' . $apiKey,
    'Content-Type: application/json'
);
// Open connection
$ch = curl_init();
// Set the URL, number of POST vars, POST data
curl_setopt( $ch, CURLOPT_URL, $url);
curl_setopt( $ch, CURLOPT_POST, true);
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
 curl_setopt($ch, CURLOPT_POST, true);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode( $fields));
$result = curl_exec($ch);
curl_close($ch);
echo $result;

I followed a tutorial which told me to add 'priority'=>'high', i did but still didn't work

user6579134
  • 749
  • 3
  • 10
  • 35
  • make sure you have proper registration device token from ios and as per your response from php there is no error.may be from ios device you have to check. – Vision Coderz Sep 27 '17 at 15:20
  • also if its success it means you have proper device token or else it will throw invalid registration – Vision Coderz Sep 27 '17 at 15:21
  • I've not used FCM, but are you in Release or Debug? If you are debugging then you must use a debug certificate and instruct FCM to connect to Apple debug APNs. – Shebuka Sep 27 '17 at 15:23
  • I’ve uploaded the .p12 file to fcm – user6579134 Sep 27 '17 at 15:25
  • Only VoIP Push certificate is same for Debug and Release. Normal Push certificates are different. – Shebuka Sep 27 '17 at 15:28

1 Answers1

0

Recently i worked on Push notification on both Firebase and APN so i can say as per your FCM response Push notification sent successfully from PHP end

so I guess you are handling some think wrong in your app side

As i am PHP developer i am not much aware of ios development.so can share some links it might help you to debug

firebase iOS not receive push notifications

Firebase when receive Push Notification did not receive the popup

iOS not receiving Firebase Push Notification sent through the API

Not receiving Push Notifications Using firebase and Objective C

Not receiving Firebase push notifications when app is open?

Vision Coderz
  • 8,257
  • 5
  • 41
  • 57
  • I am facing almost similar problem My server sending data message to a topic, it is working in Android but unable to receive in IOS, on other hand when I send message from firebase console then IOS works well, what my guess is, server sending data message in a format that IOS not supporting may be wrong key value pairs etc, can you please tell me that what should be the format of data message that I want to receive in IOS, or there is predefined keys that server side need to use. – Hafiz Shoaib Awan Apr 04 '19 at 16:12