Skip to content
This repository has been archived by the owner on Jun 6, 2021. It is now read-only.

Notify IOS Devices Via GCM #146

Open
arcoslwm opened this issue Oct 18, 2016 · 0 comments
Open

Notify IOS Devices Via GCM #146

arcoslwm opened this issue Oct 18, 2016 · 0 comments

Comments

@arcoslwm
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant