Code Monkey home page Code Monkey logo

Comments (13)

carsten-klaffke avatar carsten-klaffke commented on August 17, 2024 3

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).

Simulator Screenshot - iPhone 15 Pro - 2024-04-03 at 09 24 26

from send-intent.

carsten-klaffke avatar carsten-klaffke commented on August 17, 2024 1

Please check out this thread 80 as it covers some potential problems with signing and deployment target!

from send-intent.

markelarizaga avatar markelarizaga commented on August 17, 2024 1

That made the trick! Thanks a lot for your support and quick responses.

from send-intent.

carsten-klaffke avatar carsten-klaffke commented on August 17, 2024

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.

from send-intent.

markelarizaga avatar markelarizaga commented on August 17, 2024

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.

from send-intent.

markelarizaga avatar markelarizaga commented on August 17, 2024

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:

Screenshot 2024-04-09 at 01 04 35

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?

from send-intent.

carsten-klaffke avatar carsten-klaffke commented on August 17, 2024

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).

from send-intent.

markelarizaga avatar markelarizaga commented on August 17, 2024

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.

from send-intent.

markelarizaga avatar markelarizaga commented on August 17, 2024

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 .

from send-intent.

carsten-klaffke avatar carsten-klaffke commented on August 17, 2024

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:

  1. ShareViewController::sendData(), check queryItems (just as you already pointed out yourself)
  2. AppDelegate::application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) , check if params are arriving properly
  3. SendIntent::checkSendIntentReceived(), check if "firstItem" in store holds the correct values

from send-intent.

markelarizaga avatar markelarizaga commented on August 17, 2024

Will do!
Thanks again for the help.

from send-intent.

markelarizaga avatar markelarizaga commented on August 17, 2024

Ok, I tried debugging the share action.

I see sendData function gets values that make sense (I'm sharing a webpage from Safari):
Screenshot 2024-06-25 at 00 17 31

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:
Screenshot 2024-06-25 at 00 22 42

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?

from send-intent.

carsten-klaffke avatar carsten-klaffke commented on August 17, 2024

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.

from send-intent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.