Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
CatchABus opened this issue Nov 3, 2022 · 0 comments · Fixed by #155
Closed

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

CatchABus opened this issue Nov 3, 2022 · 0 comments · Fixed by #155

Comments

@CatchABus
Copy link
Contributor

CatchABus commented Nov 3, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant