Home >Backend Development >PHP Tutorial >Why Are GCM Notifications Not Being Received in iOS Background Mode?
GCM Notifications Not Received in iOS Background Mode
Push notifications sent by GCM may not be received by iOS devices when the app is in the background. This can be attributed to several factors. Here's an analysis of the issue and its resolution:
Problem 1: Notifications Not Received in Background
Problem 2: "Could not connect to GCM" Error
PHP Code Solution
Add the following modifications to your PHP script:
<code class="php">$data = array( 'message' => 'Hello World!', 'body' => 'Hello World!', ); $post = array( 'registration_ids' => $ids, 'data' => $data, 'content_available' => true, // To trigger when iOS app is in background 'priority' => 'high', 'notification' => $data, // Send notification payload );</code>
iOS Code Solution
No modifications are required on the iOS side, but ensure you have followed the instructions provided by the GCM documentation to correctly implement the GCM service.
Additional Tips
The above is the detailed content of Why Are GCM Notifications Not Being Received in iOS Background Mode?. For more information, please follow other related articles on the PHP Chinese website!