-2

I want to open viber application. I have a phone number and when user tap button I want to open a suitable chat or just open Viber application.

I already tried all of the version but nothing works for me.

Launching Viber app via URL scheme on iOS

guard let viberURL = URL(string: "viber://chat?number=0123456789") else { return }
                    
        if UIApplication.shared.canOpenURL(viberURL) {
            UIApplication.shared.open(viberURL, options: [:], completionHandler: nil)
        }
Rezo Joglidze
  • 321
  • 1
  • 3
  • 15
  • If Viber supports a custom URL scheme you could use the UIApplication method `open(_:options:completionHandler:)` to invoke a Viber URL. I believe that's the only way. – Duncan C Aug 18 '23 at 12:44
  • Can you share some lines of code? – son Aug 18 '23 at 12:44
  • I don't have any handy. I gave you the method signature. Look it up in the Xcode docs. – Duncan C Aug 18 '23 at 12:46
  • I updated the question. now you can to see the lines of code – Rezo Joglidze Aug 18 '23 at 12:47
  • What does "nothing works for me" mean? Does the app open but fail to connect a call? Does it fail to open? Does it display a message to the user? – Duncan C Aug 18 '23 at 12:50
  • You might also try calling "canOpenURL(_:)" to ask the system "...if the device has an installed app registered to handle the URL’s scheme." (a quote from the docs.) – Duncan C Aug 18 '23 at 12:51
  • You might also try contacting the company that developed Viber and asking them. – Duncan C Aug 18 '23 at 12:52

0 Answers0