Open alishhid opened 6 months ago
Did you walk through all the steps describe in README? You need to ceate a "Share Extension", register your URL Scheme and create an app group.
I'm having a similar issue, and my first bet is I have something odd in my config. But I have a question. Should I see my app listed as a share target in the iOS simulator or does the simulator have any kind of limitation for this to work? I don't have a real device handy so I was wondering if I should be able to operate normally with the send-intent plugin provided that I have my config properly implemented.
Hello @markelarizaga , yes, you should see it in the virtual device, too. The example app should be working on iOS (SendIntentExample) and should illustrate a complete configuration. You see the SendIntentExample-option in the image scrrenshot below (Virtual Device).
Hi again, I installed the example app in my simulator, which simulates an iPhone 15 Pro with iOS 16.2, and when trying to share a webpage via Safari, I see this:
As you see the example app is not listed for some reason. My understanding is that just checking out the example code, building it in Xcode and running it should be enough, right? I don't need to change any groups, url schemes or anything, correct?
Hello @markelarizaga, might be a stupid question but did you try clicking on "... mas"? If it is really not listed, maybe signing is a problem. This is configured individually in XCode (Targets -> Signing and Capabilities).
Haha, it's not a stupid question at all, but yes, I tried clicking in Más (which for context means More in Spanish) but the app is not there either. As you say, I tend to think on something around the app config on my side. I will keep trying. Thanks a lot for your quick responses.
Please check out this thread 80 as it covers some potential problems with signing and deployment target!
I just realized I never answered back. I finally made it and my app appears among the share targets in iOS. It was something in the app config to be tweaked in Xcode. However, now I am facing a different issue. When sharing, say, a website from safari, my app opens correctly but the object passed to handleIntent contains only empty values:
window.addEventListener("sendIntentReceived", () => {
SendIntent.checkSendIntentReceived()
.then(handleIntent)
.catch(handleError);
});
function handleIntent(result) {
// result is { title: "", description: "", type: "", url: "", additional-terms: "" }
}
Any clue? I gave a look to the swift code in the documentation and the closest thing I see that could generate such an object is this:
let queryItems = shareItems.map {
[
URLQueryItem(
name: "title",
value: $0.title?.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) ?? ""),
URLQueryItem(name: "description", value: ""),
URLQueryItem(
name: "type",
value: $0.type?.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) ?? ""),
URLQueryItem(
name: "url",
value: $0.url?.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) ?? ""),
]
}.flatMap({ $0 })
Unfortunately I never worked with Swift so everything I can make are guesses. Let me know if you prefer to open a new issue @carsten-klaffke .
It's hard to tell what is going wrong from here. You could debug or log some code positions to see where the info is getting lost. For this, I would suggest:
Will do! Thanks again for the help.
Ok, I tried debugging the share action.
I see sendData function gets values that make sense (I'm sharing a webpage from Safari):
However, the app doesn't seem to stop in the app delegate.
I'm seeing this in Xcode when I set a line to debug:
And it says something like: Xcode won't stop in this line because it has not been resolved
. Can it be there is something in my config that is making the app not run that code?
I also spotted a difference between my code and the docs/examples in this repo. In AppDelegate, this line:
let store = ShareStore.store
Was causing a compilation error: "Cannot find 'ShareStore' in scope"
.
I overcome the build error this causes by adding the following code into the file:
public final class ShareStore {
public static let store = ShareStore()
private init() {
self.shareItems = []
self.processed = false
}
public var shareItems: [JSObject]
public var processed: Bool
}
Honestly I don't know how I reached this code, but it makes the build error disapear and run the app. Can this be related to my problem?
I would assume that the new definition of ShareStore is causing the problem. You are writing to the wrong object, so the plugin can't read the data. Your AppDelegate::application(...
)-call should be fine, as the "sendIntentReceived"-event is fired and catched properly in your JS-Code. So don't worry about the breakpoint that doesn't cause a stop (probably a non-debuggable line)! To get rid of the error "Cannot find 'ShareStore' in scope"
, try refreshing, cleaning and rebuilding your project/pods! It should be found.
That made the trick! Thanks a lot for your support and quick responses.
@markelarizaga what exactly did you do to fix this issue? I'm having the exact same problem
@markelarizaga what exactly did you do to fix this issue? I'm having the exact same problem
Hi, in my case I just followed @carsten-klaffke's advice:
try refreshing, cleaning and rebuilding your project/pods! It should be found.
This worked for me. Is your error the same as me? The code not being able to find ShareStore?
Hey @markelarizaga thanks for replying.
I didn't really understand what "refreshing, cleaning and rebuilding your project/pods" meant, but I was able to figure it out through asking chatgpt.
I did end up getting it working and the above advice from @carsten-klaffke was part of the solution for me. I'm pretty unfamiliar with all this iOS stuff so I personally found the instructions hard to follow - had to ask chatgpt for help. I'm not exactly sure what else was causing problems for me, but one thing I know I missed in the instructions was setting the app group id on both the ShareExtension and the main app.
Since multiple people have run into this issue now, I think it would be worthwhile to add instructions on how to refresh/clean/rebuild the project/pods.
I guess the moral of this story is, when you get stuck, ask chatgpt.
I think this is more like a general problem with Xcode and Pods. It can happen at different occasions - or not. So instructions here in this repo are not easy to do and probably not the right place. But we have these issue discussions now, where one might find help, too. And I agree, ChatGPT is great.
Actually the issue is configuration provided in the plugin documentation for ios is not working. i have added the configuration in info.plist but still my app is not appearing in mobile sharelist.