achorein / expo-share-intent-demo

React Native Expo Share Intent Demonstration
90 stars 9 forks source link

Conflict with react-native-google-signin #19

Closed magnum6actual closed 8 months ago

magnum6actual commented 1 year ago

Great work on this - very helpful. I'm having a problem, though. I ran the demo - no issues, worked first try. I ported the same code over to my app, everything looks like it works, my app is recognized in the share menu, but when I send it, the app never opens. I have isolated the issue down to how google signin is setup. In my app.json, I have the following:

"ios": {
      "supportsTablet": true,
      "bundleIdentifier": "co.nutrios.feedme",
      "googleServicesFile": "./GoogleService-Info.plist",
      "associatedDomains": ["com.googleusercontent.apps.942641703715-6h7o8bgmlaecrprlpech57qcfbsmon7n"],
      "infoPlist": {
        "CFBundleURLTypes": [
          {
            "CFBundleTypeRole": "Editor",
            "CFBundleURLSchemes": ["com.googleusercontent.apps.942641703715-6h7o8bgmlaecrprlpech57qcfbsmon7n"]
          }
        ]
      }
    },

when I remove the infoPlist entry - everything works fine. So, I assume this entry is overwriting whatever the react-native-receive-sharing-intent does to designate what it listens to in order to open the app. I am brand new to React Native, and it's my only exposure to iOS development. Any ideas on how to deconflict? Without the infoPList data above, Google Signin won't work.

magnum6actual commented 1 year ago

Figured this out. The CFBundleURLTypes in app.json overwrites the entries react-native-google-signin drops in. Without the infoPlist in my app.json there is an entry of app name and iOS bundle identifier in CFBundleURLSchemes. So, I just added those into the array in app.json with the entry becoming:

"CFBundleURLSchemes": [{reversed google iOS Client ID}, {app name}, {bundle identifier}]

or, in my case:

"CFBundleURLSchemes": ["com.googleusercontent.apps.942641703715-6h7o8bgmlaecrprlpech57qcfbsmon7n"], "feedme", "co.nutrios.feedme"]

There may be some more elegant way to do this, but it's all working now.

achorein commented 1 year ago

👋 It seem not related to the share-intent implementation, you had no problem with the Plist before using the demo plugin?

magnum6actual commented 1 year ago

Everything worked fine with google login. I added share-intent, and share-intent would sort of work. I could see my app in the iOS share options, but nothing was ever sent to the app. We I removed the google login infoPlist entry from app.json, the share-intent worked fine, but I could no longer use Google login. To get them to both work together, I had to add the app name and bundle identifier to the CFBundleURLSchemes in infoPlist in my app.json. I suspect in the build process, share-intent writes its value to CFBundleURLSchemes, but then it's overwritten by the Google Signin required additions to infoPlist. So, I'm just hard coding what the build process does through the plug in.

FelipeLujan commented 9 months ago

Hi, im having the same issue. I'm using Google one tap sign in. From app.config.js

 plugins: [
     ...
      [
        "expo-config-plugin-ios-share-extension",
        {
          activationRules: {
            NSExtensionActivationSupportsWebURLWithMaxCount: 1,
            NSExtensionActivationSupportsWebPageWithMaxCount: 1,
            NSExtensionActivationSupportsText: true,
          },
        },
      ],
...
]
ios: {
      googleServicesFile: "./GoogleService-Info.plist",
      supportsTablet: true,
      bundleIdentifier: "bundleIdentifier",
      appExtensions: [
        {
          targetName: "ShareExtension",
          bundleIdentifier:
            "bundleIdentifier.share-extension",
          entitlements: {
            "com.apple.security.application-groups": [
              "group.com.bundleIdentifier",
            ],
          },
        },
      ],
    },

When I try to share a website, my app shows up amongst other apps, when I tap it a popup is displayed for half a second before disappearing. My app never receives the link.

I'm not an iOS developer, however; the contents of the ios folder look fairly similar to these instructions

I copied /patches and /plugins from the expo 49 branch onto my project's root folder and I have "postinstall": "patch-package" in the scripts of my package.json

Is there anything specific I should be looking at?

achorein commented 9 months ago

Your configuration looks good. Did you try magnum6actual trick ?

For my part I use expo-auth-session/providers/google in a project and it works without problem.

FelipeLujan commented 9 months ago

I have, now it looks app.config.js looks like this

 ios: {
      entitlements: { "com.apple.developer.applesignin": ["Default"] },
      usesAppleSignIn: true,
      googleServicesFile: "./GoogleService-Info.plist",
      supportsTablet: true,
      bundleIdentifier: "com.mycompany.myapp",
      infoPlist: {
        CFBundleURLTypes: [
          {
            CFBundleTypeRole: "Editor",
            CFBundleURLSchemes: [
              "com.googleusercontent.apps.99999999999-aaaaaaaa",
              "Read Summary",
              "com.mycompany.myapp",
            ],
          },
        ],
      },
    }

I also tried commenting out@react-native-google-signin/google-signin from the plugins array, and then generating a clean prebuild.

Unfortunately, the issue persists in both the emulator and my ipad

achorein commented 8 months ago

entitlements looks wrong, I think it override your share extension build config in ios/ShareExtension/ShareExtension.entitlements

try removing it or replacing it with something like that :

entitlements: { "com.apple.developer.applesignin": ["Default", "group.com.mycompany.myapp"] }
FelipeLujan commented 8 months ago

I applied that change, the behavior still persists. Another setting I made sure to apply is setting the iOS target minimum deployment version to the same as the main bundle.

Not sure if this has any impact but the share extension folder doesn't show up in the project navigator when I open the .xcworkspace file in xcode. I mean, the target shows up below the main app but not in the Project navigator as when I create the share extension manually

achorein commented 8 months ago

The incompatibility with react-native-google-signin will be handled in the new package expo-share-intent. feel free to reopen an issue there.