bradvin / social-share-urls

Social Share URLs
BSD 3-Clause "New" or "Revised" License
2.78k stars 304 forks source link

Viber works #645

Closed emin-grbo closed 4 years ago

emin-grbo commented 4 years ago

Just tested the viber example that is already there, and it works just fine ;)

HoldOffHunger commented 4 years ago

Hey, roblack.

I have tested Viber at least four times since 2014. It worked the first time, but not in 2018, and, just now, I tested it again, 2020. Still does not work. In fact, I recorded it:

https://www.youtube.com/watch?v=3NHb2J0swZ4&feature=youtu.be

It comes up with a "Forward To Who:" blank select screen, even though I have numerous contacts who have Viber also installed.

And let's be clear. The official documentation says NOT to use the above format: https://developers.viber.com/docs/tools/deep-links/

What happens when you use the actual, official format? I get a completely different form screen on my share URL, and it still -- does not work.

HoldOffHunger commented 4 years ago

Merely opening the Viber app or Viber.com isn't sufficient. These are supposed to be URL's for social sharing, not just plain URL's to websites.

emin-grbo commented 4 years ago

Hey man! Tnx for the reply! I just tested it now in the app where i added this to. Here is the usage i have that still works:

_ = viberShare.reactive.tapGesture().observeNext { (_) in
            self.socialShare(url: "viber://forward?text=",
                             fallBack: "https://apps.apple.com/us/app/viber-messenger-chats-calls/id382617920")
        }

And here is the socialShare function:

    func socialShare(url: String, fallBack: String) {
        let urlString = url + (currentNews.webLink ?? "")
        let fallBackURL = URL(string: fallBack)

        guard let appUrl = URL.init(string:urlString.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)!) else {return}

        if UIApplication.shared.canOpenURL(appUrl)
        {
            UIApplication.shared.open(appUrl)
        } else {
            UIApplication.shared.open(fallBackURL!)
        }
    }

Hope this helps!

HoldOffHunger commented 4 years ago

Hey, roblack,

That does help! Thanks!

I'm going to look at this issue again in the morning. See if maybe I was just hitting a bad server in the cluster or something. Functionality might be looking cleaner, then, who knows.

Thanks for contributing! I'll post further if I find anything.