Visitar URL original
Convert APNs tokens to Firebase registration tokens · Issue #664 · beste/firebase-php · GitHub
Skip to content

Convert APNs tokens to Firebase registration tokens #664

Open

Description

@halaei

Describe the feature you would like to see

I just wondering if you find it fit to add batchImport method to this library. The API converts APNs tokens to Firebase tokens. I hope it will be a handy feature for iOS app developers, since the iOS devices give us APNs tokens instead of Firebase messaging tokens, which need to be converted in server side.

The API reference: https://developers.google.com/instance-id/reference/server#create_registration_tokens_for_apns_tokens

Using the Instance ID service's batchImport method, you can bulk import existing iOS APNs tokens to Google Cloud Messaging or Firebase Cloud Messaging, mapping them to valid registration tokens. Call the Instance ID service at this endpoint, providing a list of APNs tokens in the JSON body:
https://iid.googleapis.com/iid/v1:batchImport
The response body contains an array of Instance ID registration tokens ready to be used for sending FCM or GCM messages to the corresponding APNs device token.

Activity

  1. github-actions commented on Sep 22, 2022

    @github-actions
    Contributor

    There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale. Please make sure to update to the latest version and check if that solves the issue. Let me know if that works for you by leaving a 👍. Because this issue is marked as stale, it will be closed and locked in 7 days if no further activity occurs. Thank you for your contributions!

  2. ni3k commented on Feb 10, 2023

    @ni3k

    I already have an implementation for this method, I could add it to the package if it is still needed/desired

  3. romk1n commented on Mar 11, 2024

    @romk1n

    That would be great.

  4. williamdes commented on Jun 24, 2024

    @williamdes

    I already have an implementation for this method, I could add it to the package if it is still needed/desired

    That would help

    Here is my lines to get it working

    use GuzzleHttp\RequestOptions;
    use Kreait\Firebase\Factory;
    
            $factory = new Factory();
            $factory = $factory->withServiceAccount(config('firebase.projects.app.credentials'));
            $googleApiClient = $factory->createApiClient([
                'base_uri' => 'https://iid.googleapis.com',
                'headers' => [
                    'access_token_auth' => 'true',
                    'User-Agent' => 'Custom UA',
                ],
            ]);
    
            $request = [
                RequestOptions::JSON => [
                    'application' => $appId,
                    'sandbox' => $sandboxMode,
                    'apns_tokens' => [
                        $apnsToken,
                    ],
                ],
            ];
    
            Context::merge([
                'request' => $request,
            ]);
    
            $response = $googleApiClient->post('/iid/v1:batchImport', $request);
  5. ni3k commented on Jun 25, 2024

    @ni3k

    Hi, the insance id api will be deprecated at the end of this month so I think it's safe to close this issue, afaik the new api does not support converting apns tokens to firebase anymore

  6. williamdes commented on Jun 25, 2024

    @williamdes

    Hi, the insance id api will be deprecated at the end of this month so I think it's safe to close this issue, afaik the new api does not support converting apns tokens to firebase anymore

    Please cite your sources, all the Google docs I checked and topics indicated this API will not be deprecated

  7. jeromegamez commented on Jun 25, 2024

    @jeromegamez
    Member

    The Instance ID API is deprecated. If you need to access unique app installation identifiers, use the Firebase installations API. See also Firebase installations and Instance ID.

    https://developers.google.com/instance-id/reference/server

    But I don't see right now that/how it impacts Admin SDKs. For the time being I think we're safe, as far as I can see, this mainly affects Client SDKs.

    it seems the new concept of "Firebase Installation Identifier" is equivalent to FCM Registration Tokens, and it provides "just" a method to delete FIDs.

    https://firebase.google.com/docs/reference/admin/node/firebase-admin.installations.installations

    in the context of Admin SDKs (not this one, yet), deleting FIDs has a caveat:

    When you delete an Firebase installation ID with a server API call, Firebase services start the process to delete the data tied to that installation ID, stop accepting new data for that ID over the course of 1-2 days, and then notify the client app that the ID was deleted. Until Firebase notifies the client app, some of

    the app's services might still target the ID—for example, a Firebase installation might continue to receive FCM notifications for a few hours.

    If you want to delete the current Firebase installation ID and immediately use Firebase services with a new, unrelated ID, use the client API to handle the deletion.

    https://firebase.google.com/docs/projects/manage-installations

    So, deleting FIDs seems to be best handled on-device.

  8. jeromegamez commented on Jun 25, 2024

    @jeromegamez
    Member

    As for the feature to convert APNS tokens to Firebase Registration IDs, this is something I cannot test, so I would have to implement it blindly. It's possible, but I would need people testing this on their projects for me.

  9. ni3k commented on Jun 25, 2024

    @ni3k

    Hi, the insance id api will be deprecated at the end of this month so I think it's safe to close this issue, afaik the new api does not support converting apns tokens to firebase anymore

    Please cite your sources, all the Google docs I checked and topics indicated this API will not be deprecated

    The Instance ID API is deprecated. If you need to access unique app installation identifiers, use the Firebase installations API. See also Firebase installations and Instance ID.

    https://developers.google.com/instance-id/reference/server

  10. williamdes commented on Jun 25, 2024

    @williamdes

    Okay, well here is my source: https://firebase.google.com/support/faq?hl=fr#fcm-23-deprecation

    https://iid.googleapis.com/iid/* The endpoints will continue to work but they won't support authentication using static server keys after 6/21/2024.

    At work, the endpoint works fine with the new auth

  11. williamdes commented on Jun 25, 2024

    @williamdes

    As for the feature to convert APNS tokens to Firebase Registration IDs, this is something I cannot test, so I would have to implement it blindly. It's possible, but I would need people testing this on their projects for me.

    For sure, batch import as coded in my example can be a starting point. For sure I will do my best to try new implementations

  12. jeromegamez commented on Jun 25, 2024

    @jeromegamez
    Member

    Indeed, this SDK doesn't use static server keys, so you should be fine 💪🏻

  13. williamdes commented on Jun 25, 2024

    @williamdes

    Could batch import be added?
    it seems like the SDK already has part of the logic of #664 (comment)

    By the way, is there some config to set the user agent globally?

  14. williamdes commented on Nov 26, 2024

    @williamdes

    Hi, the insance id api will be deprecated at the end of this month so I think it's safe to close this issue, afaik the new api does not support converting apns tokens to firebase anymore

    The API still works to this day, with my code sample. Can it be implemented here ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions