appinioGmbH / flutter_packages

Dart and Flutter plugins/packages used and maintained by @appinioGmbH
185 stars 208 forks source link

[ BUG ] : Not actually posted on facebook #282

Closed keanallen closed 1 month ago

keanallen commented 3 months ago

Plugin name Appinio social share

Describe the bug I implemented facebook sharing, I tried to share a screenshot from my device. The preview of the image to be shared is successfully rendered on the facebook pre-post preview, but when I started to click on "Post" it shows a successful message saying "Shared to facebook", but it is not actually shared.

Expected behavior It should be posted on my timeline.

Screenshots none

NOTE This works on android. But not in iOS

Smartphone:

Additional context

ListTile(
                  leading: const FaIcon(FontAwesomeIcons.facebook),
                  title: const Text('Share on Facebook'),
                  onTap: () async {
                    requestStoragePermission();

                    await screenshotController
                        .capture(delay: const Duration(milliseconds: 10))
                        .then((image) async {
                      if (image != null) {
                        String fileName =
                            DateFormat('yyyyMMddHHmmss').format(DateTime.now());
                        final directory = Platform.isIOS
                            ? await getApplicationDocumentsDirectory()
                            : await getExternalStorageDirectory(); // Use getExternalStorageDirectory instead
                        final imagePath = '${directory!.path}/$fileName.png';
                        File imageFile = File(imagePath);
                        try {
                          // Save the captured image to the device
                          await File(imagePath).writeAsBytes(image);
                          print('Image saved at: $imagePath');
                          // Check if the file exists after saving
                          if (await imageFile.exists()) {
                            print('Image file exists after saving');
                          } else {
                            print('Image file does not exist after saving');
                          }
                          // Share the saved image to Facebook
                          await AppinioSocialShare()
                              .shareToFacebook('', [imagePath]);
                        } catch (e) {
                          print('Error saving image: $e');
                        }
                      }
                    });
                    Navigator.pop(context);
                  },
                ),

Info.plist

<key>CFBundleURLTypes</key>
        <array>
            <dict>
                <key>CFBundleURLSchemes</key>
                <array>
                    <string>fbf2625472f954a01ec1c88eceaab08e2b</string>
                </array>
            </dict>
        </array>

        <key>LSApplicationQueriesSchemes</key>
        <array>
            <string>instagram</string>
            <string>fb</string>
            <string>fbauth2</string>
            <string>fbshareextension</string>
            <string>fbapi</string>
            <string>facebook-reels</string>
            <string>facebook-stories</string>
            <string>fb-messenger-share-api</string>
            <string>fb-messenger</string>
            <string>tg</string>
            <string>whatsapp</string>
            <string>twitter</string>
        </array>

        <key>NSPhotoLibraryUsageDescription</key>
        <string>$(PRODUCT_NAME) needs permission to access photos and videos on your device</string>
        <key>NSCameraUsageDescription</key>
        <string>$(PRODUCT_NAME) requires access to the camera.</string>
        <key>NSAppleMusicUsageDescription</key>
        <string>$(PRODUCT_NAME) requires access to play music</string>

        <key>FacebookAppID</key>
        <string>395107006792804</string>
        <key>FacebookClientToken</key>
        <string>f2625472f954a01ec1c88eceaab08e2b</string>
        <key>FacebookDisplayName</key>
        <string>Puro - Hearing Test</string>

        <key>NSBonjourServices</key>
        <array>
            <string>_dartobservatory._tcp</string>
        </array>
keanallen commented 3 months ago

Need insight on this. As we are scheduled to go live this friday.

keanallen commented 3 months ago

@khanmujeeb687 any feedback?

khanmujeeb687 commented 1 month ago

Hey @keanallen , I tested this feature on ios with version 0.3.1 and it seems to work perfectly fine. The flow is same as you described but its getting successfully posted and also visible on my profile.

Please try the latest version of the plugin here.

Closing this issue, if issue still persist please reopen it.