skip to Main Content

Now that the legacy Firebase APIs are being deprecated, it appears this might include the Instance ID Server APIs.

We are currently using the Instance ID Server APIs ‘batchImport’ method to convert APNS tokens to FCM device registration tokens on the back-end.

Is it using the Firebase Admin SDK to do the same thing? To convert an APNS token to an FCM device registration token? Or is it even necessary anymore to be able to send a push-notification to an iOS device using the Admin SDK? Can we use the APNS token directly?

Thanks —

2

Answers


  1. Chosen as BEST ANSWER

    We use this endpoint: string url = "https://iid.googleapis.com/iid/v1:batchImport";

    enter image description here

    Per the FAQ, we can continue to call batchImport but we will need to use an OAuth 2.0 access token.

    When the legacy FCM APIs are disabled using the Google Cloud Admin Console, we receive the following error message from the Instance ID Server API when trying to use the Server Key:

    [1]: https://i.sstatic.net/9QieiELK.png

    The HTTP request code to the batchImport remains the same except that we need to add an OAuth token instead of the FCM Server Key:

    var access_token = string.Empty;
    try
    {
        var app = FirebaseApp.Create(new AppOptions()
        {
            Credential = GoogleCredential.FromFile("service-account-file.json")
        });
        access_token = app.Options.Credential.UnderlyingCredential.GetAccessTokenForRequestAsync().Result;
    }
    catch (Exception ex)
    {
        Console.WriteLine("Error Creating Firebase App: " + ex.Message);
    }
    
    // Add header access_token_auth
    client.DefaultRequestHeaders.Add("access_token_auth", "true");
    
    // Set OAuth Access Token in Authorization header
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", access_token);
    

  2. I also have same problem. I have to update APN authentication key to my FCM project?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search