LEVIS OGCPAS
LEVIS OGCPAS

Reputation: 229

Swift - Passing URL Query to App and using it as variable

Good day! I just want to ask if passing data to an app using an url is possible? For example. i have this link. myapp://name=BrunoMars&gender=Male&age=26&occupation=Singer Now when i click that link, it will open my app and it will pass the data to it like this

    let name = fromUrl.name
    let gender = fromUrl.gender
    let age = fromUrl.age
    let occupation = fromUrl.occupation

    self.nameLabel.text = name
    self.genderLabel.text = gender
    self.ageLabel.text = age
    self.occupationLabel = occupation

So I'm able to show it on my app. Thanks!

Upvotes: 0

Views: 780

Answers (1)

Kyle Redfearn
Kyle Redfearn

Reputation: 2281

Yes, you can do this. You need to set up your app with a custom URL scheme. See Implementing Custom URL Schemes on this page. You basically have to set a few values in your app's Info.plist and then you can send it anything you can in a URL

Upvotes: 1

Related Questions