QnaList > Groups > Android-Gcm > Mar 2016
faq

Gcm Play Sound

Hello, 
I am creating an app with ionic and ngCordova. The app shell receive push 
notifications. 
I have adopted an example from ngCordova. 
http://ngcordova.com/docs/plugins/pushNotifications/ 
My .run method looks like this: 
  .run(function ($ionicPlatform, $rootScope, User, $cordovaDialogs, 
$cordovaVibration, $cordovaPush) { 
         $ionicPlatform.ready(function () { 
                 var androidConfig = { 
                     "senderID": "xxx", 
                 }; 
                 $cordovaPush.register(androidConfig).then(function(result) 
{ 
                     // Success 
                 }, function(err) { 
                     // Error 
                 }) 
                 $rootScope.$on('$cordovaPush:notificationReceived', 
function(event, notification) { 
                     switch(notification.event) { 
                         case 'registered': 
                             if (notification.regid.length > 0 ) { 
                                 console.debug('registration ID'); 
                                 console.debug(notification.regid); 
                             } 
                             break; 
                         case 'message': 
                             // this is the actual push notification. its 
format depends on the data model from the push server 
                             alert('message = ' + notification.message + ' 
msgCount = ' + notification.msgcnt); 
                             break; 
                         case 'error': 
                             alert('GCM error = ' + notification.msg); 
                             break; 
                         default: 
                             alert('An unknown GCM event has occurred'); 
                             break; 
                     } 
                 }); 
             }); 
     }) 
I send push notifications with the following script: 
https://github.com/mattg888/GCM-PHP-Server-Push-Message 
The messages arrive, as far so good. 
But I can't manage to play a sound/tone. According to GCM documentation, 
this should work with the parameter sound and the value default. 
My GCM request looks like this: 
 $apiKey = "YOUR GOOGLE API SERVER KEY"; 
 $devices = array('YOUR REGISTERED DEVICE ID'); 
 $message = "The message to send"; 
 $gcpm = new GCMPushMessage($apiKey); 
 $gcpm->setDevices($devices); 
 $response = $gcpm->send($message, array('title' => 'Test title', 'sound' 
=> 'default')); 
Has someone an idea why the sound is not played? 
Thank you in advance! 
You received this message because you are subscribed to the Google Groups "android-gcm" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-gcm/824df40c-b7d6-49bf-946a-68307a6d25aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

asked Mar 30 2016 at 02:34

alexander.heithn-websolutions.com's gravatar image



Related discussions

Tagged

Group Android-gcm

asked Mar 30 2016 at 02:34

active Mar 30 2016 at 02:34

posts:1

users:1

©2013 QnaList.com