Launching Viber app via URL scheme on iOS

2019-01-09 13:23发布

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.

8条回答
我欲成王,谁敢阻挡
2楼-- · 2019-01-09 13:52

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

查看更多
Lonely孤独者°
3楼-- · 2019-01-09 13:53

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:

support@viber.com:

"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
查看更多
淡お忘
4楼-- · 2019-01-09 13:53

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

查看更多
5楼-- · 2019-01-09 13:53
viber://contact?number= mobile number

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

查看更多
看我几分像从前
6楼-- · 2019-01-09 13:54

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.

查看更多
Deceive 欺骗
7楼-- · 2019-01-09 13:56

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
}
查看更多
登录 后发表回答