Crashing on iOS when sharing from specific apps
itaibs opened this issue · 5 comments
Hi!
First of all, thanks for the amazing package. Super helpful for our project.
I have everything set up and working on both android and iPhone. On android everything works perfectly and same is true for iPhone when sharing from chrome/safari.
But when trying to share from YouTube (and some other apps as well, e.g., notes) the share extension crashes with the next exception (I found on the console logs):
Exception '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]' was thrown while invoking data on target ReactNativeShareExtension with params (
6,
7
)
I have no idea what to do about this. Would appreciate any input :).
Thanks!
@itaibs I have built this only for browsers to share links. One thing you can do is put the breaking point here and try to see why it causes that error. I'm going to look into this issue in few days as I progress in my app. if you can solve this I'm more than happy to accept your PR. other than that you have to wait couple of days before I get into this issue.
@alinz Thanks for the quick reply!
Considering my knowledge of native iOS programming is 0, I don't think I can be much help.
Glad to hear this is already something you plan on doing!
In the meanwhile, do you know how I can prevent the extension of showing up when sharing from unsupported apps?
@itaibs one thing you should know that you need to set NSExtensionAttributes
in your plist file for your app in order apple accept your app. Maybe you can dig into this and see if you can limit the access of share extension in certain area. You can look into this and search for Declaring Supported Data Types for a Share or Action Extension
.
let me know if you find something, it would be nice if you can document it and send a PR to this repo.
@alinz Thanks for the heads up.
From what you are saying, I conclude (and please correct me if I'm wrong) that the following should be in Info.plist:
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
</dict>
</dict>
I have done this in my project and indeed the result is that my extension shows when sharing from browsers and doesn't show when sharing from apps like "Notes". YouTube, however, still shows my extension, I'm guessing because it does actually share a url.
So as far as I understand, there's nothing to be done about that for now, correct?
I'd be happy to add this step to the Readme.md if you think this is right (considering this doesn't fully solve the issue).