Launching Viber app via URL scheme on iOS
Asked Answered
C

10

8

I'm making an iOS app which can open Viber app and automatically call a person or go to chat window with the person. Is there any url scheme for Viber to do that such as:

viber://tel:<phone_number>
viber://chat:<phone_number>

I followed this link but it's for Android.

Causalgia answered 30/5, 2015 at 3:5 Comment(0)
U
9

I sent a mail to the Viber support and they told me that this kind of URL (opening Viber call/chat with a phone number) are no more supported. When typing Viber version is 5.6.

Look at their answer:

[email protected]:

"Thank you for contacting us. Unfortunately, there isn’t such option in Viber."


The only thing I've found is an url to forward a message: https://www.viber.com/en/developers/share_on_viber you can specify the text but not the recipient

Example:

viber://forward?text=foo
Unreal answered 6/10, 2015 at 10:53 Comment(0)
L
15

as for now (26.03.2017), I found this URI are working:

  • viber://add?number=NUMBER - open user page
  • viber://forward?text=foo - share text with selected users
  • viber://chats - opens chat tab
  • viber://calls - opens calls tab
  • ??? - can't find how to open user's/contacts tab
  • viber://public - opens a public tab
  • viber://more - open more tab (the last one in the row)

and some links to interact with Public Accounts https://developers.viber.com/tools/deep-links/index.html - viber://pa?chatURI=hello&context=abcdefg&text=hi - attempt to wrte hi to hello public account

support forum: https://support.viber.com/

and they have chrome extension - https://support.viber.com/customer/en/portal/articles/2191386-new-chrome-web-extension#top

Loggins answered 26/3, 2017 at 15:28 Comment(1)
But when the user's device doesn't have Viber software/mobile installed it's don't respond to anything. It's confusing for users. Is there any way to show them any message or something if they don't have installed Viber on their device?Supreme
U
9

I sent a mail to the Viber support and they told me that this kind of URL (opening Viber call/chat with a phone number) are no more supported. When typing Viber version is 5.6.

Look at their answer:

[email protected]:

"Thank you for contacting us. Unfortunately, there isn’t such option in Viber."


The only thing I've found is an url to forward a message: https://www.viber.com/en/developers/share_on_viber you can specify the text but not the recipient

Example:

viber://forward?text=foo
Unreal answered 6/10, 2015 at 10:53 Comment(0)
J
7
viber://contact?number= mobile number

It will open the particular user contact. Give user to select chat and call.
it worked for me!

Jesusa answered 31/5, 2017 at 10:18 Comment(0)
C
5

I've found one way to "almost" call using Viber - by adding contact:

viber://add?number=0123456789

This will open Viber "Add Contact" dialog, and user can finally call expected number after adding it as a new contact.

Tested this on 5.6 Viber. Also works from HTML:

<a href="viber://add?number=%2B49150123456789">Viber me</a>

However, if contact doesn't exist, the first click would only open the Dialog, save new contact and go back to your application/page. Clicking the same link again will open directly contact view with Call out button

Cheers!

Colossus answered 19/12, 2015 at 21:8 Comment(0)
T
4

You could use this code to accomplish what you want:

NSString *phoneNumber = @"1112223333";
NSString * const viberScheme = @"viber://";
NSString * const tel = @"tel";
NSString * const chat = @"chat";
NSString *action = @"<user selection, chat or tel>"; // this could be @"chat" or @"tel" depending on the choice of the user

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:viberScheme]]) {

    // viber is installed
    NSString *myString;
    if ([action isEqualToString:tel]) {
        myString = [NSString stringWithFormat:@"%@:%@", tel, phoneNumber];
    } else if ([action isEqualToString:chat]) {
        myString = [NSString stringWithFormat:@"%@:%@", chat, phoneNumber];
    }

    NSURL *myUrl = [NSURL URLWithString:[viberScheme stringByAppendingString:myString]];

    if ([[UIApplication sharedApplication] canOpenURL:myUrl]) {
        [[UIApplication sharedApplication] openURL:myUrl];
    } else {
        // wrong parameters
    }

} else {
    // viber is not installed
}
Themis answered 30/5, 2015 at 15:32 Comment(2)
This does redirect me to viber , but results in an alert saying "Requesting page is unavailable" .Mcwhirter
If everything is correct it could mean Viber for iOS does not support this feature. My recommendation is to try a website that opens the Viber native iOS app and see the url used. It is a reverse-engineering task, I know.Themis
L
4

This points to the contact page

viber://contact?number=38095xxxxxxx

IMPORTANT: Don't put + at the beginning of the number, it won't work otherwise

Library answered 7/9, 2019 at 12:6 Comment(3)
Viber didn't recognize number without +. After I added plus it work as expected.Weiss
It's not working for me. Is this still supported by viber?Guiltless
@Guiltless it's working. I tested it today.Arabeila
H
1

This works: "viber://chats" or "viber://calls"

Holocene answered 6/6, 2015 at 13:47 Comment(0)
R
0

For Swift, you can do like that :)

let viberShareUrl = "viber://forward?text=\(shareUrl)"
let url:NSURL =NSURL(string: viberShareUrl)!  
UIApplication.sharedApplication().openURL(url)
Rundell answered 1/11, 2016 at 8:49 Comment(1)
While this code snippet may solve the question, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, not just the person asking now! Please edit your answer to add explanation, and give an indication of what limitations and assumptions apply.Milicent
D
0

I don't know if this is available on iOS but it works for me on Viber Desktop Windows 10.

<a href="viber://chat?number=0912222222" class="viber"></a>

It will open a chat window with the intended person. Tested on 2021 Jul 07.

Daughterly answered 19/7, 2021 at 4:57 Comment(2)
URI viber://chat?number=NUMBER is working for today (I think as well as URI mentioned in other answers), but there is one important thing to make it work on iOS - do not forget to add viber scheme to Queried URL Schemes in Info.plist.Arguello
what kind of scheme? where can i find it?Camarillo
H
-2

You can check by using

[[UIApplication sharedApplication] canOpenURL:@"viber://url"];

if Viber app is installed on device, and viber handle this url scheme it will return true otherwise false.

Hamner answered 30/5, 2015 at 13:2 Comment(1)
This code does not work, please post working code. canOperURL: expects an NSURL and you are passing an NSStringThemis

© 2022 - 2024 — McMap. All rights reserved.