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

My app showing in share sheet but when i share my app not opening #10

Open
qasimali09 opened this issue Jan 22, 2024 · 10 comments
Open
Labels
question Further information is requested
Milestone

Comments

@qasimali09
Copy link

No description provided.

@OutdatedGuy
Copy link
Owner

Hi @qasimali09, provide some information for me to debug this issue like

  1. Code snippet (text, not image)
  2. Platform
  3. Plugin version
  4. Screen recording of the issue

@Nathanael-Rayapin
Copy link

Nathanael-Rayapin commented Feb 26, 2024

Hi @OutdatedGuy ,
I have the same problem as @qasimali09, so I'll take the liberty of providing some information:

After following to the letter what was indicated in the iOS installation process, when I share a video from the gallery, I am not brought back to my application. The gallery pretends to close, but nothing happens and no video appears in my project,I have no Xcode errors or logs when this happens.

I literally copied and pasted everything that was indicated in the installation, the only difference being in my use of ReceiveSharingIntentPlus in my project:

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
import 'package:receive_sharing_intent_plus/receive_sharing_intent_plus.dart';

import '../services/navigation_service.dart';

class ShareIntentUtils {
  static File? sharedVideo;

  static late GlobalKey<NavigatorState> _navigatorKey;

  static Future<bool> initListeners() async {
    Logger logger = Logger('ShareIntentUtils');
    _navigatorKey = NavigationService().navigatorKey;
    // For sharing images coming from outside the app while the app is in the memory
    ReceiveSharingIntentPlus.getMediaStream().listen((List<SharedMediaFile> sharedFiles) {
      logger.info("Received mediaStream while app is in memory: ${sharedFiles.map((e) => e.path)}");
      if (sharedFiles.isNotEmpty) {
        onVideoReceived(File(sharedFiles.first.path));
      }
    }, onError: (err) {
      logger.severe("getIntentDataStream error:", err);
    });

    // For sharing images coming from outside the app while the app is closed
    List<SharedMediaFile> sharedFiles = await ReceiveSharingIntentPlus.getInitialMedia();
    logger.info("Received mediaStream while app is closed: $sharedFiles}");
    if (sharedFiles.isNotEmpty) {
      onVideoReceived(File(sharedFiles.first.path));
    }
    return sharedFiles.isNotEmpty;
  }

  static onVideoReceived(File receivedVideo) {
    sharedVideo = receivedVideo;
    if (Platform.isIOS) {
      _navigatorKey.currentState?.pushReplacementNamed('/publish');
    }
  }
}

Flutter 3.19.1
Apple M1 Pro

@Nathanael-Rayapin
Copy link

@OutdatedGuy Here the screen recording of the problem

Screen.Recording.2024-02-27.at.13.55.07.mov

@OutdatedGuy
Copy link
Owner

Hi @Nathanael-Rayapin, can you try sharing with images and pdfs? So we can narrow down to what exactly is causing this issue.

Also can you try the same on Android emulator and tell what happens? Thanks

@OutdatedGuy OutdatedGuy added the question Further information is requested label Feb 29, 2024
@Nathanael-Rayapin
Copy link

Hi, so i tried to take images from the gallery, but neither the image nor the video would fit. On Android, the same thing happens, except that this time it manages to open my application.

@OutdatedGuy
Copy link
Owner

OutdatedGuy commented Feb 29, 2024

Can you provide your ios/Runner/info.plist and AndroidManifest.xml contents.

Edit: And also ios/Share Extension/info.plist.

@Nathanael-Rayapin
Copy link

Nathanael-Rayapin commented Mar 1, 2024

ios/Runner/info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CADisableMinimumFrameDurationOnPhone</key>
    <true/>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleDisplayName</key>
    <string>$(BUNDLE_DISPLAY_NAME)</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(BUNDLE_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>$(FLUTTER_BUILD_NAME)</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>AppGroupId</key>
<string>$(CUSTOM_GROUP_ID)</string>
    <key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>ShareMedia-$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    </array>
  </dict>
</array>
<key>NSPhotoLibraryUsageDescription</key>
<string>To upload photos, please allow permission to access your photo library.</string>
    <key>CFBundleVersion</key>
    <string>$(FLUTTER_BUILD_NUMBER)</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>LSSupportsOpeningDocumentsInPlace</key>
    <true/>
    <key>FirebaseAppDelegateProxyEnabled</key>
    <true/>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Proposer des tags localisés</string>
    <key>UIApplicationSupportsIndirectInputEvents</key>
    <true/>
    <key>UIBackgroundModes</key>
    <array>
        <string>fetch</string>
        <string>remote-notification</string>
    </array>
    <key>UILaunchStoryboardName</key>
    <string>qualLaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
</dict>
</plist>

AndroidManifest.xml :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.project.video">
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="28" tools:replace="android:maxSdkVersion"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/>
    <uses-permission android:name="android.permission.READ_MEDIA_VIDEOS" />
    <!--  Permissions pour les notifications  -->
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <application
        android:name="${applicationName}"
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher"
        android:allowBackup="false"
        android:fullBackupContent="@xml/backup_rules">
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
        <meta-data
            android:name="google_analytics_automatic_screen_reporting_enabled"
            android:value="false" />
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTask"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="image/*" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="video/*" />
            </intent-filter>
            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.yalantis.ucrop.UCropActivity"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
    <queries>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="https" />
        </intent>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.APP_BROWSER" />
            <data android:scheme="https" />
        </intent>
        <intent>
            <action android:name="android.intent.action.SENDTO" />
            <data android:scheme="mailto" />
        </intent>
    </queries>
</manifest>

ios/Share Extension/info.plist :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>AppGroupId</key>
  <string>$(CUSTOM_GROUP_ID)</string>
  <key>NSExtension</key>
  <dict>
    <key>NSExtensionAttributes</key>
    <dict>
      <key>PHSupportedMediaTypes</key>
      <array>
        <!-- TODO: Add this flag, if you want to support sharing video into your app -->
        <string>Video</string>
        <!-- TODO: Add this flag, if you want to support sharing images into your app -->
        <string>Image</string>
      </array>
      <key>NSExtensionActivationRule</key>
      <dict>
        <!-- TODO: Add this flag, if you want to support sharing images into your app -->
        <key>NSExtensionActivationSupportsImageWithMaxCount</key>
        <integer>100</integer>
        <!-- TODO: Add this flag, if you want to support sharing video into your app -->
        <key>NSExtensionActivationSupportsMovieWithMaxCount</key>
        <integer>100</integer>
      </dict>
    </dict>
    <key>NSExtensionMainStoryboard</key>
    <string>MainInterface</string>
    <key>NSExtensionPointIdentifier</key>
    <string>com.apple.share-services</string>
  </dict>
</dict>
</plist>

@OutdatedGuy
Copy link
Owner

Hi, you shared ios/Share Extension/Share Extension.entitlements instead of ios/Share Extension/info.plist.

But aside from that, I don't see any issues. Can you clean build the project again with;

flutter clean;
flutter pub get;
cd ios;
pod repo update;
pod install;

@ItsMeLucifer
Copy link

I experienced the same problem (On Android worked perfectly, on iOS the app didn't open). It didn't work on the iOS emulator, but when I ran the app in release mode on a physical device - It worked, so maybe the emulator is the problem.

@OutdatedGuy
Copy link
Owner

@ItsMeLucifer, thanks for the insights. I'm currently on the way to upgrade the plugin and solve many problems, however my new plugin code in not working on emulator.

I'll try it on a real device and see what happens.

@OutdatedGuy OutdatedGuy added this to the v2.0.0 milestone Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants