Skip to content

Data-Only Push Notifications #86

Description

@GavynHolt

We are beginning to implement data-only push notifications in our Skip Tools app, and are noticing that the SkipFirebaseMessaging onMessageReceived method is swallowing our messages on the Android side.

At the moment on the iOS side background notifications are not supported in the main NotificationDelegate, so we have decided to do something like this in our AppMainDelegate:

    func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
        // ... logic here to process notification
        //  AppDelegate.shared.onDidReceiveRemoteNotification(userInfo)
    }

On Android, we are seeing that Firebase handles both Banner style and background style notifications through the onMessageReceived method, but in the Skip implementation, if there is no notification, it performs a silent early return:

    public override func onMessageReceived(message: RemoteMessage) {
        super.onMessageReceived(message)
        guard let activity = UIApplication.shared.androidActivity, let notification = message.notification else {
            return
        }

As I look more deeply into this method I see this is highly dependant on the NotificationDelegate pattern and may be a bit tough to untangle.

One idea we have had is to add a new func to the Skip-provided App Delegate, which would be in charge of handling these silent notifications:

public final class RspndrGuardAppDelegate : Sendable {
...
    public func onLowMemory() {
        logger.debug("onLowMemory")
    }
    
    public func onDidReceiveRemoteNotification(_ userInfo: [AnyHashable: Any]) {
        logger.debug("didReceiveRemoteNotification: \(userInfo)")
        Task { @MainActor in
            NotificationManager.shared.handleNotificationData(userInfo: userInfo)
        }
    }

With this idea, we are struggling firstly with the fact that SkipFirebaseMessaging does not allow a message without a notification, but secondly, are not quite sure how to send the notification up to the delegate on the Android side perhaps from the internals of the onMessageReceived method or otherwise.

We are prepared to submit a fix if this would be helpful, but I just wanted to raise this before we start to modify any skip packages to first ask: Does this seem like the right avenue to support data-only notifications? Is there anything I am missing that could be much simpler?

Thank you,
-Gavyn

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions