Android 용 모바일 웹 사이트 (응용 프로그램 아님)의 WhatsApp에 대한 링크 공유
휴대 전화에서 주로 사용되는 웹 사이트를 개발했습니다.
사용자가 웹 페이지에서 WhatsApp으로 직접 정보를 공유 할 수 있도록하고 싶습니다.
UserAgent 감지를 사용하여 Android와 iOS를 구별 할 수 있습니다.
iOS에서 위를 구현하기 위해 URL을 사용할 수 있음을 발견했습니다.
href="whatsapp://send?text=http://www.example.com"
OS가 Android 일 때 위의 방법으로 작동하지 않는 솔루션을 찾고 있습니다.
안드로이드에서 "의도"를 사용하는 것과 관련이 있다고 생각하지만 href의 매개 변수로 사용하는 방법을 알 수 없었습니다.
그냥 웹 사이트에서 보았고 최신 크롬과 whatsapp가있는 최신 Android에서도 작동하는 것 같습니다! 링크에 새로운 기회를주세요!
<a href="whatsapp://send?text=The text to share!" data-action="share/whatsapp/share">Share via Whatsapp</a>
(17 그것을 오늘 다시 확인해 번째 4 월 2015 년)
아이폰 OS 팔에 나를 위해 작품 (아이폰 6, 최신 버전) 안드로이드 5 (넥서스 5, 최신 버전).
Windows Phone에서도 작동합니다.
위의 답변은 약간 구식입니다. 이러한 방법은 작동하지만 아래 방법을 사용하면 미리 정의 된 숫자로 모든 텍스트를 공유 할 수 있습니다. 아래 방법은 안드로이드, WhatsApp 웹, IOS 등에서 작동합니다.
이 형식을 사용해야합니다.
<a href="https://api.whatsapp.com/send?phone=whatsappphonenumber&text=urlencodedtext"></a>
업데이트-지금부터 사용하십시오 (2018 년 11 월)
<a href="https://wa.me/whatsappphonenumber/?text=urlencodedtext"></a>
사용 : https://wa.me/15551234567
사용하지 마십시오 : https://wa.me/+001-(555)1234567
채팅의 텍스트 필드에 자동으로 표시되는 미리 채워진 메시지로 자신 만의 링크를 만들려면 https://wa.me/whatsappphonenumber/?text=urlencodedtext를 사용 하십시오. 여기서 whatsappphonenumber는 국제 형식 및 URL의 전체 전화 번호입니다. -encodedtext는 URL로 인코딩 된 미리 채워진 메시지입니다.
예 : https://wa.me/15551234567?text=I 'm % 20interested % 20in % 20your % 20car % 20for % 20sale
미리 채워진 메시지로 링크를 만들려면 https://wa.me/?text=urlencodedtext를 사용 하십시오.
예 : https://wa.me/?text=I 'm % 20inquiring % 20about % 20the % 20apartment % 20listing
링크를 클릭하면 메시지를 보낼 수있는 연락처 목록이 표시됩니다.
자세한 내용은 https://www.whatsapp.com/faq/en/general/26000030을 참조 하십시오.
현재, 이것을 달성하는 것은 매우 쉽습니다. 페이지에 다음 코드 만 추가하면됩니다.
<a href="whatsapp://send?text=<<HERE GOES THE URL ENCODED TEXT YOU WANT TO SHARE>>" data-action="share/whatsapp/share">Share via Whatsapp</a>
그리고 그게 다야. 자바 스크립트가 필요하지 않으며 다른 것도 필요하지 않습니다. 물론 원하는대로 스타일을 지정하고 멋진 Whatsapp 아이콘을 포함시킬 수 있습니다.
Chrome을 사용하는 Android 기기에서 이것을 테스트했습니다. 버전 :
- 안드로이드 4.1.2 (젤리 빈)
- Chrome 모바일 37.0.2062.117. Firefox Mobile 31.0에서도 테스트되었습니다.
- WHATSAPP V 2.11.399
iOS에서도 작동합니다. Safari를 사용하여 iPhone 5에서 빠른 테스트를 수행했으며 잘 작동합니다.
이것이 누군가를 돕기를 바랍니다. :-)
새 문서에 따르면 링크는 다음과 같습니다.
<a href="https://wa.me/?text=urlencodedtext">Share this</a>
작동하지 않으면 다음을 시도하십시오.
<a href="whatsapp://send?text=urlencodedtext">Share this</a>
최근 WhatsApp은 공식 웹 사이트 에서 모바일 사이트와 공유 할 수 있도록이 HTML 태그를 사용해야한다고 업데이트했습니다 .
<a href="whatsapp://send?text=Hello%20World!">Hello, world!</a>
당신 text=
은 당신의 링크 또는 텍스트 내용을 가지고 교체 할 수 있습니다
Android 용 WhatsApp은 현재 웹 브라우저에서 호출하는 것을 지원하지 않습니다.
현재 프로젝트와 동일한 요구 사항이 있었고 적절한 정보를 찾을 수 없으므로 APK 파일을 다운로드했습니다.
Android에서 애플리케이션을 웹 브라우저에서 호출하려면 android.intent.category.BROWSABLE 카테고리로 활동을 정의해야합니다.
이에 대한 자세한 정보는 https://developers.google.com/chrome/mobile/docs/intents 에서 확인할 수 있습니다.
WhatsApp AndroidManifest.xml 파일을 살펴보면 BROWSABLE 범주의 유일한 Activiy는 다음과 같습니다.
<activity android:name="com.whatsapp.Conversation" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:windowSoftInputMode="stateUnchanged">
<intent-filter>
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
</intent-filter>
</activity>
나는 잠시 동안 그것을 가지고 놀고 있었고, 그것을 작동시킬 수 없었다. 내가 얻은 것은 Chrome에서 WhatsApp 응용 프로그램을 여는 것이었지만 메시지 내용과 수신자를 설정하는 방법을 알 수 없었습니다.
그것은 WhatsApp 팀에 의해 문서화되지 않았기 때문에 여전히 진행 중이라고 생각합니다. 앞으로 WhatsApp은 SMS도 처리 할 것 같습니다.
더 많은 정보를 얻는 유일한 방법은 WhatsApp dev 팀에 연락하는 것입니다.하지만 시도한 내용이 아직 기다리고 있습니다.
문안 인사!
일반적으로 Java 스크립트를 사용하여 iOS 또는 Android 장치에만 Whatsapp 링크를 표시하는 것이 좋습니다.
if (navigator.userAgent.match(/iPhone|Android/i)) {
document.write('<a href="whatsapp://send?text=See..">Share on WhatApp</a>');
}
Just tested the whatsapp://
scheme on my super old Android 2.3.3
with Whats App 2.11.301
, works like a charm. It seems to be just the Whats App
version. Since Whats App
is forcing everyone to update, it should be safe to use it.
The Whats App
documentation also mention that scheme: http://www.whatsapp.com/faq/en/android/28000012
I'm using this on a production site now and will update here, if I get any user complaints.
Edit (Nov 14): No user complaints after a couple of weeks.
LATEST UPDATE
Now you can use the latest API from whatsapp https://wa.me/
without worrying about the user agent, the API will do the user agent handling.
Share pre-filled text with contact selection option in respective whatsapp client (Android / iOS / Webapp):
https://wa.me/?text=urlencodedtext
Open Chat Dialog for a particular whatsapp user in respective whatsapp client (Android / iOS / Webapp):
https://wa.me/whatsappphonenumber
Share pre-filled text with a particular user (Combine above two):
https://wa.me/whatsappphonenumber/?text=urlencodedtext
Note : whatsappphonenumber
should be full phone number in international format. Omit any zeroes, brackets or dashes when adding the phone number in international format.
For official documentation visit https://faq.whatsapp.com/en/general/26000030
TLDR: "This is not supported." ~ Official Whatsapp Developer.
I tested this on several devices (Android, iOS, and Windows), and it simply does not work. This was one out of 40 different services I tested personally, and the only one out of two that did not work (the other being Viber). See the list here..
https://github.com/bradvin/social-share-urls#whatsapp
In frustration, I e-mailed the developers at WhatsApp. I showed them their own source :
https://faq.whatsapp.com/en/android/26000030/?category=5245251
I was told, very specifically, THIS FEATURE IS NOT IMPLEMENTED.
"Unfortunately, that is not supported at the moment.
We are always working to improve our app and will take your suggestion into consideration.
request #172349248330585"
In order to test this: (1) Register for a Whatsapp account, (2) Install Whatsapp on your desktop, (3) Install Whatsapp an your phone, (4) Sync your phone and computer, (5) Build and upload a whatsapp share link on your private host, (6) click it in devices mentioned in 2 and 3. (7) Click the link, see that Whatsapp opens, see also that it completely ignores all parameters given to it.
All of these produced failure for Viber and Whatsapp, and positive results for 38 other services (from Google to Skype to Line.me to Facebook, Digg, StumbleUpon, Douban, you name it).
use it like "whatsapp://send?text=" + encodeURIComponent(your text goes here), it will definitely work.
Try to make it this way:
<a href="https://wa.me/(phone)?text=(text URL encoded)">Link</a>
Even you can send messages without enter the phone number in the link:
<a href="https://wa.me/?text=Hello%20world!">Say hello</a>
After clicking on the link, you will be shown a list of contacts you can send your message to.
More info in https://faq.whatsapp.com/en/general/26000030.
Good luck!
Switch the whatsapp share links according to the platform whether desktop or mobile.
This works with or without providing the phone number in the link.
For Mobile
vm.LinkTextToShare = 'https://api.whatsapp.com/send?text=' + encodeURIComponent(window.location.href) ;
window.open(vm.LinkTextToShare,"_blank");
For Desktop
vm.LinkTextToShare = 'https://web.whatsapp.com/send?l=en&text=' + encodeURIComponent(window.location.href) ;
window.open(vm.LinkTextToShare,"_blank");
'IT' 카테고리의 다른 글
JavaScript는 스크롤의 창 X / Y 위치를 얻습니다. (0) | 2020.05.13 |
---|---|
글꼴이 멋진 입력 유형 '제출' (0) | 2020.05.13 |
ExpressJS에서 404 오류를 페이지로 리디렉션하는 방법은 무엇입니까? (0) | 2020.05.13 |
iOS 6의 라벨 정렬-UITextAlignment 사용 중단 (0) | 2020.05.13 |
인터페이스 생성시기를 어떻게 알 수 있습니까? (0) | 2020.05.13 |