ShekarMudaliyar / social_share

Flutter package to share images/videos/text on social media
https://pub.dev/packages/social_share
MIT License
112 stars 191 forks source link

Instagram and Facebook Stories Crash - [__NSPlaceholderDictionary initWithObjects:forKeys:count:] #106

Closed DennisAshford closed 2 years ago

DennisAshford commented 2 years ago

I am generated a watermarked image, then a dynamic link, that will eventually be shared to Instagram of Facebook.

final newImage = await _socialShareService.sharedImage();

//then image is saved to Firebase and dynamic link generated
final postsUpdateData = createPostsRecordData(
     sharedImage: newImage);
await containerPostsRecord.reference.update(
      postsUpdateData);

var uri = await _dynamicLinkService
      .createDynamicLink()
print(uri.toString());

//this is where the error is occurring
await SocialShare.shareInstagramStory(newImage,
       backgroundBottomColor: "#000000",
       backgroundTopColor: "#ffffff",
       attributionURL: uri.toString());

Everything works fine up until Instagram or Facebook need to be called to open, and then I receive the following error and crash report

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(0x180e350fc 0x199685d64 0x180f3e564 0x180f496e0 0x180df2514 0x180e10ebc 0x1059d0358 0x108c0e75c 0x108747cf8 0x108ad5bb4 0x1089fd1c0 0x108a00f24 0x180e4a318 0x180dcecf0 0x180dc94ec 0x180da7d08 0x180dbb468 0x19c95f38c 0x18375e5d0 0x1834dcf74 0x104597b68 0x1052d1aa4)
libc++abi: terminating with uncaught exception of type NSException
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00000001b84f7964 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
->  0x1b84f7964 <+8>:  b.lo   0x1b84f7984               ; <+40>
    0x1b84f7968 <+12>: pacibsp 
    0x1b84f796c <+16>: stp    x29, x30, [sp, #-0x10]!
    0x1b84f7970 <+20>: mov    x29, sp
Target 0: (Runner) stopped.

I am not sure exactly how to read the report, but from reading online it seems like it is coming from the AppDelegate.swift function for iOS. This occurs for both Instagram and Facebook Stories share and I also tried defining a background image, which also didn't work. This is a slightly different error than others reported since it appears to be with Keys. Both are added to my Info.plist file:

<key>LSApplicationQueriesSchemes</key>
    <array>
    <string>instagram-stories</string>
        <string>facebook-stories</string>
        <string>facebook</string>
        <string>instagram</string>
        <string>twitter</string>
        <string>whatsapp</string>
    </array>

Any help is greatly appreciated!

DennisAshford commented 2 years ago

I was able to figure this error out. I was using an url path instead of a file path for the image. Bug closed.