Please consider the following problem:
I use the following plugin for Xamarin to execute push notifications, I am trying to run this on both iOS and Androids.
https://github.com/CrossGeeks/FirebasePushNotificationPlugin
I also use the following PHP code to send push notifications to a device from a website.
$fields = array ( 'to' => $ID->notification_token, "content_available" => true, 'priority'=>10, 'notification' => array('title' => 'You have a new message', 'body' => 'Hooray', 'sound'=>'default', 'vibration'=>'default'), ); $headers = array ( 'Authorization: key=' . PUSH_NOTIFICATION_API_ACCESS_KEY, 'Content-Type: application/json', ); $ch = curl_init(); curl_setopt( $ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send' ); curl_setopt( $ch,CURLOPT_POST, true ); curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers ); curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false ); curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) ); $result = curl_exec($ch ); curl_close( $ch ); echo $result;
Now the problem is in iOS. I find that the push notification is reliable and works fine when the application is in the foreground, but as soon as I close it (or lock the screen), they stop passing until I precede it again, all notifications sent at that the time when they were in the background, everything immediately passes.
I have included background processes in my info.plist , as per the Getting Started plugins.
I tried changing the content_availiable to content-availiable , also moving it to the notification array, also setting its value to true , 'true' , 1 and '1'
I also tried adding "alert" => "" both the notification and the general payload, however I still can't get it to work, outside the unlocked foreground state.
I also notice that nothing happens in the actual list of notifications (popped from the top of the screen), the only way I know that receiving notifications is to play a specific sound file as it arrives and is recorded in the debug log.
Any help would be appreciated, thanks for your time.