Can Firebase notifications coexist with APNs?

1.1k Views Asked by At

I am writing an iOS SDK which receives push notifications.

Up until now, we asked the app developers to give us a push key so we can send push messages to the app. The developers add some routing code to their APNs listener, simple implementing -

if push.hasKey('forSDK') and push['forSDK']:
    send_push_to_sdk
else:
    do_the_app_thing

This is tedious and requires coordination with the app developers whenever their token expires. Moreover, we found that using Firebase notifications for iOS is much simpler than connecting to APNs.

Is there a way to use Firebase notifications (for the SDK) alongside the App's APNs, so that I can omit the routing code?

enter image description here

1

There are 1 best solutions below

0
On

On the receiving side

If the hosting app is using straight APNs, if you don't want to have your developers add the routing logic to their didReceiveRemoteNotification: you have two options:

  1. Implement a - (BOOL)handleIncomingNotification: in your SDK, and have the developer always call it, like so:

    BOOL handled = [AdamMatanSDK handleIncomingNotification:userInfo];
    if (!handled) {
        // developer does their own logic here (do_the_app_thing)
    }
    
  2. Or your SDK can swizzle the hosting app's app delegate's didReceiveRemoteNotification: so it can check the notification before calling the app delegate's original method.

On the sending side:

You can certainly use Firebase Notifications alongside APNs directly, as Firebase uses APNs to send iOS push notifications.

However, you would still need your developers to keep you updated with their APNs push certificates if you were to send them push notifications via APNs. If this is tedious to do now, you could save a bit of tedium by using Firebase Notifications, because you'd have a GUI to manage the certs.

You could manage these certificates in your own Firebase console, or perhaps the developer can maintain the push certificates themselves in their own Firebase console, and invite you, as the SDK developer, to access their Firebase project. Either way, you would see a list of Firebase projects, and switch into them to send a push notification, or use Firebase's Cloud Messaging HTTP API to programmatically send pushes to each Firebase project.