How do I generate an html link for Viber?

I install a button on the site (html link) to start the chat in Viber:

Option #1

<a href="viber://chat?number=+387771234567"><i class="fab fa-viber"></i>Viber</a>

If you click on the link viber://chat?number=+ on your computer, the viber app starts and a dialog opens with the owner of the phone number. Problem: Clicking on this link is not intercepted by the viber app installed on the smartphone.

Option #2

<a href="viber://add?number=387771234567"><i class="fab fa-viber"></i>Viber</a>

If you click on the link viber://add?number= (characters + no in-line link), an app on a smartphone it works out adding a contact (starting a chat is a separate user action that he still needs to perform independently), but this link is incorrectly intercepted by the application installed on the desktop, which gives the error "the action cannot be performed".

Technically, the solution is to check the device via HTTP_USER_AGENT and generate a string for the html link depending on this.

Please tell me if this is the right way, or if there is a universal solution. a solution for creating and processing links for your smartphone and desktop?

Author: 118_64, 2019-07-18

1 answers

Put the url character code %2b instead of the plus sign +.

 0
Author: , 2019-07-18 14:46:12