richsage / RMSPushNotificationsBundle

NOT MAINTAINED! ⛔️ Push notifications/messages for mobile devices. Supports iOS, Android (C2DM, GCM), Blackberry and Windows Mobile (toast only). A Symfony2 bundle.
MIT License
321 stars 152 forks source link

Notify IOS Devices Via GCM #146

Open arcoslwm opened 7 years ago

arcoslwm commented 7 years ago

hi, first of all thanks for the bundle, performance with GCM is very good. I've been trying to use 'AndroidMessage' and 'RMS\PushNotificationsBundle\Service\Notifications' class to notify IOS devices having the client application integrated with GCM but I do not get to see notifications in the app even though the method 'getResponses(Types::OS_ANDROID_GCM)' reports OK however using this function i can see notifications in the app client:

sendGoogleCloudMessage($data, $ids) {
        // Insert real GCM API key from Google APIs Console
        // https://code.google.com/apis/console/        
        $apiKey = 'xxxxxxxxxxxxxxxxxxxxxxx';

        // Define URL to GCM endpoint
        $url = 'https://gcm-http.googleapis.com/gcm/send';

        // Set GCM post variables (device IDs and push payload)     
        $post = array(
            'registration_ids' => $ids,
            'content_available' => true,
            'priority' => 'high',
            'data' => $data,             
        );

        // Set CURL request headers (authentication and type)       
        $headers = array(
            'Authorization: key=' . $apiKey,
            'Content-Type: application/json'
        );

        // Initialize curl handle       
        $ch = curl_init();

        // Set URL to GCM endpoint      
        curl_setopt($ch, CURLOPT_URL, $url);

        // Set request method to POST       
        curl_setopt($ch, CURLOPT_POST, true);

        // Set our custom headers       
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

        // Get the response back as string instead of printing it       
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        // Set JSON post data
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post));

        // Actually send the push   
        $result = curl_exec($ch);

        // Error handling
        if (curl_errno($ch)) {
            return 'GCM error: ' . curl_error($ch);
        }

        // Close curl handle
        curl_close($ch);

        // Debug GCM response       
        return $result;
    }

somebody has tried or achieved send notifications to IOS devices via GCM using the bundle? can someone guide me about it? Beforehand thank you very much