Skip to content
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

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent #123

Closed
daywong1119 opened this issue Nov 1, 2021 · 4 comments

Comments

@daywong1119
Copy link

🐛 Bug Report

I am trying to test the login function on Android 12, when i confirmed the login dialog, the app will crash and shows error in logcat

To Reproduce

Use android 12 emulator or real device.
Use "react-native-fbsdk-next": "^4.6.0"
Login in by facebook and confirm the dialog

Expected Behavior

Should be able to login

Environment

System:
OS: macOS 11.4
CPU: (20) x64 Intel(R) Core(TM) i9-10910 CPU @ 3.60GHz
Memory: 2.05 GB / 64.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.22.1 - ~/.nvm/versions/node/v12.22.1/bin/node
Yarn: 1.22.10 - ~/.nvm/versions/node/v12.22.1/bin/yarn
npm: 6.14.12 - ~/.nvm/versions/node/v12.22.1/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
Android SDK:
API Levels: 23, 24, 25, 26, 27, 28, 29, 30, 31
Build Tools: 23.0.1, 23.0.2, 23.0.3, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 27.0.3, 28.0.2, 28.0.3, 29.0.2, 29.0.3, 30.0.0
System Images: android-25 | Google APIs Intel x86 Atom, android-25 | Google Play Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-30 | Google Play Intel x86 Atom, android-31 | Google Play Intel x86 Atom_64
Android NDK: Not Found
IDEs:
Android Studio: 4.2 AI-202.7660.26.42.7486908
Xcode: 12.5/12E262 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_191 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.1 => 17.0.1
react-native: 0.64.2 => 0.64.2
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Log

    Process: app.AAAAA.BBBBB, PID: 12387
    java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=64206, result=-1, data=Intent { (has extras) }} to activity {app.AAAAA.BBBBB/app.drivergram.MainActivity}: java.lang.IllegalArgumentException: app.AAAAA.BBBBB: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
        at android.app.ActivityThread.deliverResults(ActivityThread.java:5301)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:5340)
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:54)
        at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2210)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7839)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
     Caused by: java.lang.IllegalArgumentException: app.AAAAA.BBBBB: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
        at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
        at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
        at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
        at com.facebook.AccessTokenManager.setTokenExpirationBroadcastAlarm(AccessTokenManager.java:164)
        at com.facebook.AccessTokenManager.setCurrentAccessToken(AccessTokenManager.java:130)
        at com.facebook.AccessTokenManager.setCurrentAccessToken(AccessTokenManager.java:110)
        at com.facebook.AccessToken.setCurrentAccessToken(AccessToken.java:245)
        at com.facebook.login.LoginManager.finishLogin(LoginManager.java:719)
        at com.facebook.login.LoginManager.onActivityResult(LoginManager.java:242)
        at com.facebook.login.LoginManager$1.onActivityResult(LoginManager.java:181)
        at com.facebook.internal.CallbackManagerImpl.onActivityResult(CallbackManagerImpl.java:81)
        at com.facebook.reactnative.androidsdk.FBActivityEventListener.onActivityResult(FBActivityEventListener.java:34)
        at com.facebook.react.bridge.ReactContext.onActivityResult(ReactContext.java:305)
        at com.facebook.react.ReactInstanceManager.onActivityResult(ReactInstanceManager.java:762)
        at com.facebook.react.ReactDelegate.onActivityResult(ReactDelegate.java:90)
        at com.facebook.react.ReactActivityDelegate.onActivityResult(ReactActivityDelegate.java:112)
        at com.facebook.react.ReactActivity.onActivityResult(ReactActivity.java:68)
        at android.app.Activity.dispatchActivityResult(Activity.java:8382)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:5294)```
@mikehardy
Copy link
Collaborator

Hi there!
No problem with the current versions of the underlying SDK: https://github.com/facebook/facebook-android-sdk/blob/sdk-version-12.0.0/facebook-core/src/main/java/com/facebook/AccessTokenManager.kt#L132

So this is better understood as a duplicate of #55 - we're open to PRs that implement the same (forward-porting to v12)

@mikehardy
Copy link
Collaborator

Duplicate of #109 as well

@daywong1119
Copy link
Author

@mikehardy Thank you for prompt response. I am trying to see if I make the change here, figuring out how to get started.

Forked the repo and cloned to local
yarn && yarn link to create local repo 'react-native-fbsdk-next'
yarn link "react-native-fbsdk-next" on my rn project to required local repo

but I still can't run react server with error Error: Unable to resolve module react-native-fbsdk-next from xxx.js

@mikehardy
Copy link
Collaborator

I am able to do these things:

git clone git@github.com:thebergamo/react-native-fbsdk-next
cd react-native-fbsdk-next
yarn
cd RNFBSDKExample
yarn && npx pod-install
yarn android
yarn ios

...and they all work. Now, in the example app the dependency to the actual react-native-fbsdk-next is on github, and it's a bit trickier to keep the files in sync while doing development since we are not doing any of the magic tricks inside the ios/android native projects or the metro bundler to reference the ../ directory.

As a quick and dirty process, I would do something like this dev-sync script so you may develop on the main library files, then sync them in to the example's node_modules folder easily

https://github.com/react-native-device-info/react-native-device-info/blob/6fbdcca03879fe3d18ab90f2831388048c09a9bf/package.json#L33

it is not a fantastic process but it's really reliable and keeps the example fairly stock

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

No branches or pull requests

2 participants