Skip to content

[messaging] args.activity.registerForActivityResult is not a function #152

Closed
@CatchABus

Description

@CatchABus
Contributor

It seems that method register here performs a registerForActivityResult call for foreground activity: https://github.com/NativeScript/firebase/blob/main/packages/firebase-messaging-core/index.android.ts#L62

There are cases that foreground activity is one that does not implement method registerForActivityResult.
For instance, there was a recent report for payments plugin that had an issue because of this.
That is because payments plugin uses an activity that extends android.app.Activity (found an example from fork of billing library): https://github.com/DimaDake/billing/blob/master/library/src/main/java/com/android/billingclient/api/ProxyBillingActivity.java

As a result, that activity became foregroundActivity resulting in error described in issue NativeScript/payments#19. Foreground activity is used for register() call here: https://github.com/NativeScript/firebase/blob/main/packages/firebase-messaging-core/index.android.ts#L274

I can see that register() call was commented out in latest firebase version but we should be careful if we are going to use it again or already use it elsewhere: https://github.com/NativeScript/firebase/blob/main/packages/firebase-messaging-core/index.android.ts#L288

We probably have to use startActivity specifically for this one, just to be sure we use an activity that supports registerForActivityResult.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @CatchABus

      Issue actions

        [messaging] args.activity.registerForActivityResult is not a function · Issue #152 · NativeScript/firebase