From an Urban Airship Offboarding document, I received the following information:
We are sorry to see you leave, but want to make your transition a smooth one. Here are some things you'll want to take care of: Make an API call to access all of your device tokens and GCM registration ID's. Why? This will provice the ability to transition those tokens and ID's so the devices that have already opted in to Push Notifications on iOS won't be prompted to do so again if the Customer owns App Bundle ID. http://docs.urbanairship.com/api/ua.html#device-listing.
I was able to successfully fetch Android APIDs registered to my application by using GET /api/apids and the information under the "APID Listing" heading at http://docs.urbanairship.com/api/ua.html#device-listing. However, I am not sure how I can use the APIDs in Firebase Cloud Messaging. What I want is to obtain all of my device tokens and Firebase Cloud Messaging registration ID's from Urban Airship, but not values that are unique to Urban Airship. It is my impression that APIDs are unique to Urban Airship in the same way that Channel IDs (obtained in Java with UAirship.shared().getPushManager().getChannelId()
) are unique to Urban Airship as well. I am trying to export device tokens from Urban Airship so that I can use them from Firebase Cloud Messaing independently from Urban Airship. In other words, I want to migrate devices off of Urban Airship. Is there a way to obtain device tokens in the same format that the FirebaseInstanceId.getInstance().getToken()
method returns them? That format would look like this:
f32EVa9yfbo:AJA91bFg53ZuQLWYSDDqPlkf4a88Lu6Gp4DoXVDJ2wRIlnjDngq0UdNnlSi7wxbbut6YX7Z1kmvyS3bhk_Zrl-1doHCf5XFdOXTThNzo4sXASWqQjHKfNa3pH2Js4Zlbf_CtRkD2Peho
Thank you.
UPDATE 1:
I found a way to obtain a GCM registration ID:
Step 1. Using GET /api/apids
to fetch Android APIDs registered to this application, along with associated metadata:
C:\curl>curl -k https://go.urbanairship.com/api/apids/ -u "<AppKey>:<MasterSecret>" -H "Content-Type: application/json" -X GET |more
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0{
"next_page" : "https://go.urbanairship.com/api/apids/?start=0584f193-07a0-49f7-b2d3-92f8e05ur6b5&limit=1000",
"apids" : [ {
"tags" : [ "City-1" ],
"alias" : null,
"active" : false,
"created" : "2017-07-17 23:02:40",
"apid" : "00027235-66b4-4433-a40f-254532d8abd1"
}, {
"tags" : [ "City-1" ],
"alias" : null,
"active" : true,
"created" : "2017-09-14 15:41:35",
"apid" : "00036ca3-d628-4353-be92-0dc6fe03afc6"
}, {
"tags" : [ "city-2" ],
"alias" : null,
"active" : true,
"created" : "2017-09-18 16:38:39",
"apid" : "000222f5-824a-42f2-8ba0-c58b4c2fb2a2"
}, {
"tags" : [ "city-2" ],
-- More --
The result was a long array that contains many apids
Step 2. Using GET /api/apids/(APID)
to get information on a particular Android APID
C:\curl>curl -k https://go.urbanairship.com/api/apids/000222f5-824a-42f2-8ba0-c58b4c2fb2a2 -u "<AppKey>:<MasterSecret>" -H "Content-Type: application/json" -X GET
{"last_registration":"2017-12-14 17:36:05","created":"2017-10-19 17:05:18","gcm_registration_id":"bIY0GH6-hqk:APA91bH2xUBtlfga2kBG0GjvjbBYrI3M72BbXc3tTo7pSuY61w1wrgOeTbEqEd5J2SmUcQx25uU8TafWk2tDP7Vf7bc0ZsQrtENlFJDNIb--LUVuZimjOegyaepPYuQvm_9gmJDsviwY","apid":"000222f5-824a-42f2-8ba0-c58b4c2fb2a2","alias":"","active":true,"tags":["city-2"]}
Now I see something returned in a format that Firebase Cloud Messaging could recognize as a device token ID, and that I could use to send a push notification from Firebase Cloud Messaging without Urban Airship:
bIY0GH6-hqk:APA91bH2xUBtlfga2kBG0GjvjbBYrI3M72BbXc3tTo7pSuY61w1wrgOeTbEqEd5J2SmUcQx25uU8TafWk2tDP7Vf7bc0ZsQrtENlFJDNIb--LUVuZimjOegyaepPYuQvm_9gmJDsviwY
Now, the complication that I see is that as you can see above, I had to provide a specific APID in order to receive the gcm_registration_id
for that APID. When I only use GET /api/apids
as I put an example in Step 1 above, I do not get any gcm_registration_id
in the returned array. This makes the process of obtaining gcm_registration_id
values extremely tedious and long, because I would have to be using GET /api/apids/(APID)
as in the example I wrote in Step 2, for every APID returned by the
"GET /api/apids" that I wrote in Step 1. If I have for example 70,000 APID values, I would have to be doing this tedious process 70,000 times unless I write a script or some way to automate the process of downloading the APIDs. Is is possible that when I use GET /api/apids
as in Step 1, that I can immediately receive as part of the arrays in the metadata, gcm_registration_id
values? That would facilitate the process of dowloading the gcm_registration_id
values so that I can use them in Firebase Cloud Messaging.
Also, I would like to receive a confirmation if the gcm_registration_id
values that I see are the device token ID values that I can use in Firebase Cloud Messaging to send push notifications to devices without using Urban Airship.
UPDATE 2:
The problem is that I need to use https://go.urbanairship.com/api/apids/{apid}
in order to see the gcm_registration_id
values, and I do not want to do that because if I have 70,000 registered devices, I would have to make 70,000 cURL queries providing each of the 70,000 {apid}
values 70,000 times. It would take forever! If I only use https://go.urbanairship.com/api/apids/
without {apid}
, the returned array does not include gcm_registration_id
values.
UPDATE 3:
Is the solution writing Java code with a request to https://go.urbanairship.com/api/apids to obtain and store an array of APID values, and then pass each element of that array as the the {apid}
to then make a loop of requests to https://go.urbanairship.com/api/apids/{apid}
in order to obtain all of the GCM/FCM device tokens registered to my app? I guess a single cURL request to https://go.urbanairship.com/api/apids may not be enough to obtain all of the GCM/FCM device tokens registered to my app; and requests, arrays, and loops in Java code may be a must in order to get those tokens I am trying to download. I will appreciate if someone could confirm this.
I received a reply from Urban Airship Support Center, and they were explaining to me that the GCM/FCM token for Android devices, they call it push_address
. I went to verify those values and I see they have the format that Firebase Cloud Messaging uses, so I could finally have a way to download the tokens using the Urban Airship API. This is the reply from their tech support:
[Name of Employee] (Urban Airship Support Center)
Dec 20, 5:10 PM PST
Hi Jaime,
This is [Name of Employee] with Urban Airship Technical Support.
Try using the
/api/channels
endpoint. Thepush_address
value should be the GCM/FCM token for Android devices. The response is paginated and contains a next_page value.If you need any help pulling the data from this endpoint, or it does not contain the data you are looking for, please let me know.
Thank you, [Name of Employee] Urban Airship Technical Support Portland, Oregon
I am using the following request for example, and you can see how I get the GCM/FCM device tokens. Note: I randomly changed characters in the tokens, but you can still see the format.
C:\curl>curl -k https://go.urbanairship.com/api/channels/ -u "<AppKey>:<MasterSecret>" -H "Content-Type: application/json" -X GET |more
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 683k 0 683k 0 0 227k 0 --:--:-- 0:00:03 --:--:-- 205k
{"ok":true,"channels":[{"channel_id":"00099045-24a4-2523-a80f-876423d8abd2","device_type":"android","installed":false,"background":false,"push_address":"c2XddiCxuLf:APA91bG8-XqUuyZKnf3A0zJI7xFi3_KsOvyS7X9t2fDYpECKhMGcMdcIjggRfFcr0GAnQCDB9qRn9goC1wcVWxT2aapu578v83LlcgsgqvPFC0dZCVNi0CTZyRA4A4B0dQY7aVgWhxh2","named_user_id":null,"alias":null,"tags":["city-1"],"tag_groups":{"timezone":["America/Costa_Rica"],"ua_android_app_version":["1.21"],"ua_locale_country":["US"],"ua_locale_language":["es"],"ua_android_sdk_version":["8.3.X"],"ua_android_version":["5.1.X"],"ua_location_enabled":["false"],"ua_opt_in":["false"],"ua_background_enabled":["false"]},"created":"2017-07-17T23:02:40","opt_in":false,"last_registration":"2017-08-05T02:33:26"},{"channel_id":"00032ba5-d613-4323-be92-0ac6fe04cfd6","device_type":"android","installed":true,"background":true,"push_address":"ceG5aSa0i6o:ERT91bF0UPUvbEzP4UnlwonfyFVc55FcecQkCesXcqhJglY5UlqIAN88VwH7xadEIoWj4FsHZsYu56jiHzUJqozPawXPGNPW71TbVFeFLVNWBkzpqDgt-8Kftj-ce_Z_vpKNIrXvlAwQ","named_user_id":null,"alias":null,"tags":["city-1"],"tag_groups":{"timezone":["America/Chicago"],"ua_android_app_version":["1.21"],"ua_locale_country":["SV"],"ua_locale_language":["es"],"ua_android_sdk_version":["8.3.X"],"ua_android_version":["6.0.X"],"ua_location_enabled":["false"],"ua_opt_in":["true"],"ua_background_enabled":["true"]},"created":"2017-09-14T15:41:35","opt_in":true,"last_registration":"2017-12-20T13:12:09"},.........
UPDATE 1: Where to find the <AppKey>:<MasterSecret>
of the code that I am showing above? It is at https://go.urbanairship.com/apps/. Go to the settings page and find it in the areas that I am highlighting with ovals below:
UPDATE 2: If we know the Urban Airship channel_id
, we can get the push_address
(what Urban Airship calls push_address
is the GCM/FCM device token ID
). For example, imagine that I know that the Urban Airship channel_id
of my phone is 88cb7c8a-a207-4136-b55f-97d7238df916
. Then I can use the Airship API (https://docs.airship.com/api/ua/) to execute the following cURL command:
C:\curl>curl -k https://go.urbanairship.com/api/channels/88cb7c8a-a207-4136-b55f-97d7238df916 -u "<AppKey>:<MasterSecret>" -H "Content-Type: application/json" -X GET |more
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 739 100 739 0 0 739 0 0:00:01 --:--:-- 0:00:01 1213
{"ok":true,"channel":{"channel_id":"88cb7c8a-a207-4136-b55f-97d7238df916","device_type":"android","installed":true,"background":true,"push_address":"cbDusDAn_zE:APA91bF9su16_w4DD5qE5OgM_4E23FvIQJa84UWtvUz7zcdFf3B9WijdL1v1IaWwQTSg74doE_RMdJiCvYH1hJgWS7ELaujxhdz1SQ24EInef9JKfz3a27PTRYreTG_vMuTYkLa5T7f5","named_user_id":null,"alias":null,"tags":["guatemala-city"],"tag_groups":{"timezone":["America/Chicago"],"ua_android_app_version":["1.24"],"ua_locale_country":["US"],"ua_locale_language":["en"],"ua_android_sdk_version":["8.3.X"],"ua_android_version":["6.0.X"],"ua_location_enabled":["false"],"ua_opt_in":["true"],"ua_background_enabled":["true"]},"created":"2018-12-26T14:56:44","opt_in":true,"last_registration":"2019-05-18T06:55:39"}}
C:\curl>