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.