I have a problem with an app using GCM, the scenario is this:
You can specify "dry_run": true option in /send
request.
I found that devices do not receive any push notifications with "dry_run": true
option, while a server get canonical_ids
response.
Here is a sample code in Ruby. You may have to install gcm
Gem beforehand.
$ gem install gcm
ask_canonical_ids.rb
require 'gcm'
require 'json'
API_KEY = "YourApiKey"
gcm = GCM.new(API_KEY)
registration_ids = [
'OldRegistrationId',
]
option = { data: { 'message' => 'Hello Gcm!' }, dry_run: true }
response = gcm.send_notification(registration_ids, option)
p response[:canonical_ids]
output of $ ruby ask_canonical_ids.rb
(formatted)
[{
:old => "OldRegistrationId",
:new => "NewRegistrationId"
}]
Again, your device will not receive any push notifications.