program tip

HTML 링크를 통해 SMS 본문 텍스트를 미리 채우는 방법

radiobox 2020. 8. 17. 08:44
반응형

HTML 링크를 통해 SMS 본문 텍스트를 미리 채우는 방법


html 링크를 사용하여 본문이 미리 채워진 SMS 앱을 여는 방법은 무엇입니까?

내가 읽은 모든 것은 sms : 18005555555? body = bodyTextHere를 나타내는 것 같습니다.

작동하지만 iPhone에서는 작동하지 않습니다. ? body = bodyTextHere를 꺼내고 sms : phonenumber 만 사용하면 작동합니다.

QR 코드가 사파리 링크를 통해이를 수행하는 여러 사례를 보았습니다. 본문 텍스트를 어떻게 미리 채울 수 있습니까?


약간 엉망이기는하지만 이것이 100 % 가능하다는 것이 밝혀졌습니다.

Android에서 작동하려면 다음 형식을 사용해야합니다.

<a href="sms:/* phone number here */?body=/* body text here */">Link</a>

iOS에서 작동하려면 다음이 필요합니다.

<a href="sms:/* phone number here */;body=/* body text here */">Link</a>

라이브 데모 : http://bradorego.com/test/sms.html("Phone and? body "및"Phone and; body "는 to : 필드와 본문 텍스트를 모두 자동으로 채워야합니다. 자세한 내용은 소스보기 정보)

최신 정보:

분명히 iOS8은 우리에게 뭔가를 바꿔야 했으므로 다른 댓글 작성자 / 응답자 덕분에 iOS를위한 새로운 스타일이 있습니다.

<a href="sms:/* phone number here */&body=/* body text here */">Link</a>

(전화 번호는 선택 사항)


나는 이것이 오래된 스레드라는 것을 알고 있지만 우연히 발견되어 일부 부품이 더 이상 관련이 없다는 것을 발견했습니다.

전화 번호를 추가하지 않고 텍스트 만 채우려면 다음을 수행 할 수 있습니다.

sms:?&body=/* message body here */

iOS 8의 경우 다음을 시도하십시오.

<a href="sms:/* phone number here */&body=/* body text here */">Link</a>

";"전환 "&"는 나를 위해 일했습니다.


모든 기호를이 순서로 넣으십시오 (코드 측면에서 가장 합리적이기 때문에이 순서로만 테스트했습니다).

본문 링크에 대한주의 ... 난 그냥 넣어 ... ;?&body=. 또한 %20어떤 공간에도 사용해야 함 알았습니다 .

나는 내 아이폰 (v. 9.2)과 다른 안드로이드에서 그것을 테스트했으며 잘 작동합니다.

이렇게하면 다른 장치에 대해 해킹해야하는 문제가 해결됩니다. SMS에서 테스트했을 때 아티팩트가 없습니다.

<a href="sms:19131234567;?&body=Question%20from%20mywebsite.com.%20%20MY%20MESSAGE%20-%20" title="Click here to TEXT US gallery token needs updating!">Send me SMS</a>

Android 및 iOS에 대해 두 개의 별도 앵커 태그가 필요하지 않습니다. 이것은 도움이 될 것입니다.

// 연락처 없음
<a href="sms:?&body=message">Text Message</a>

// 연락처 번호 포함
<a href="sms:1234567890;?&body=message">Text Message</a>

// Android 및 iOS 모두에서 작동


제안 된 방법을 찾고 테스트했습니다.

<a href="sms:12345678?body=Hello my friend">Send SMS</a>

결과는 다음과 같습니다.

  • iPhone4-오류 (메시지 본문이 비어 있음)
  • Nokia N8-ok (메시지 본문- "Hello my friend", To "12345678");
  • HTC Mozart-오류 ( "지원되지 않는 페이지"메시지 ( "Send sms"링크를 클릭 한 후));
  • HTC
    Desire- 오류 ( "Invalid recipients (s) : <12345678? body = Hellomyfriend>"메시지 ( "Send sms"링크를 클릭 한 후)).

따라서 적어도이 방법으로는 작동하지 않는다고 결론을 내립니다.


SMS : 및 mailto : 링크를 자바 스크립트없이 iPhone과 Android 모두에서 작동하려면 다음을 시도하세요.

<a href="sms:321-555-1111?&body=This is what I want to sent">click to text</a>


<a href="mailto:someone@sample.com?&subject=My subject&body=This is what I want to sent">click to email</a>

Android 및 iPhone 용 Chrome과 iPhone의 Safari에서 테스트했습니다.
그들은 모두 예상대로 작동했습니다. 그들은 전화 번호 나 이메일 주소 없이도 일했습니다.


Bradorego의 솔루션이 저에게 효과적이지만 여기에 더 확장 된 답변이 있습니다.

작은 고려 사항은 %20대신을 사용하여 본문을 인코딩해야한다는 것입니다 +. PHP rawurlencode($body)의 경우 urlencode($body). 그렇지 않으면 공백 대신 이전 버전의 iOS에서 메시지에 더하기 기호가 표시됩니다.

다음은 iOS 장치 용 SMS 링크를 다시 맞추는 jQuery 기능입니다. Android / 기타 기기는 정상적으로 작동하며 코드를 실행하지 않습니다.

HTML :

<a href="sms:+15551231234?body=Hello%20World">SMS "Hello World" to 555-123-1234</a>

jQuery :

(function() {
  if ( !navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ) return;

  jQuery('a[href^="sms:"]').attr('href', function() {
    // Convert: sms:+000?body=example
    // To iOS:  sms:+000;body=example (semicolon, not question mark)
    return jQuery(this).attr('href').replace(/sms:(\+?([0-9]*))?\?/, 'sms:$1;');
  });
})();

Consider using a class like a.sms-link instead of a[href^="sms:"] if possible.


<a href="###" data-telno="13800000000" data-smscontent="hello" class="XXXXX XXXXXX XXXXXX sendsms"/>

$('.sendsms').on('click', function(){
    var p = $(this).data('telno'),
        c = $(this).data('smscontent'),
        t = ';';

    if (!ios) { // add your own iOS check
        t = '?';
    }
    location.href = 'sms:'+ p + t + c;
})

The iPhone doesn't accept any message text, it will only take in the phone number. You can see this here https://developer.apple.com/library/ios/featuredarticles/iPhoneURLScheme_Reference/SMSLinks/SMSLinks.html#//apple_ref/doc/uid/TP40007899-CH7-SW1


Well not only do you have to worry about iOS and Android, there's also which android messaging app. Google messaging app for Note 9 and some new galaxys do not open with text, but the samsung app works. The solution seems to be add // after the sms:

so sms://15551235555

<a href="sms:/* phone number here */?body=/* body text here */">Link</a>

should be

<a href="sms://15551235555?body=Hello">Link</a>

<a href="sms:/* phone number here */&body=/* body text here */">Link</a>

This works on my iPhone 5S!


I suspect in most applications you won't know who to text, so you only want to fill the text body, not the number. That works as you'd expect by just leaving out the number - here's what the URLs look like in that case:

sms:?body=message

For iOS same thing except with the ;

sms:;body=message

Here's an example of the code I use to set up the SMS:

var ua = navigator.userAgent.toLowerCase();
var url;

if (ua.indexOf("iphone") > -1 || ua.indexOf("ipad") > -1)
   url = "sms:;body=" + encodeURIComponent("I'm at " + mapUrl + " @ " + pos.Address);
else
   url = "sms:?body=" + encodeURIComponent("I'm at " + mapUrl + " @ " + pos.Address);

   location.href = url;

(Just a little bit of topic), but maybe if you searched you could stumble here... In markdown (tested with parsedown and on iOS / android) you could do :

   [Link](sms:phone_number,?&body=URL_encoded_body_text)
   //[send sms](sms:1234567890;?&body=my%20very%20interesting%20text)

For using Android you use below code

<a href="sms:+32665?body=reg fb1>Send SMS</a>

For iOS you can use below code

<a href="sms:+32665&body=reg fb1>Send SMS</a>

below code working for both iOs and Android

<a href="sms:+32665?&body=reg fb1>Send SMS</a>

I found out that, on iPhone 4 with IOS 7, you CAN put a body to the SMS only if you set a phone number in the list of contact of the phone.

So the following will work If 0606060606 is part of my contacts:

<a href="sms:0606060606;body=Hello my friend">Send SMS</a>

By the way, on iOS 6 (iPhone 3GS), it's working with just a body :

<a href="sms:;body=Hello my friend">Send SMS</a>

Every OS version has a different way of doing it. Take a look at the sms-link library


One of the problems with a click-to-text link is solving the desktop scenario where no native texting app exists. A solution is to use Zipwhip's Click-to-Text button creator.

  • On the desktop, they send you an actual real text message behind the scenes from the user's input.
  • On iOS or Android you get the native texting functionality instead.

https://www.zipwhip.com/create-sms-button/


Android and iOS body only:

<a href="sms://;?&body=Hello%20World">Only body</a>

Android and iOS one recipient only with body:

<a href="sms://+15552345678;?&body=Hello%20World">one recipient only with body</a>

Only Android multiple recipients with body:

<a href="sms://+15552345678, +15552345679;?&body=Hello%20World">Android multiple recipients with body</a>

Only iOS multiple recipients with body:

<a href="sms://open?addresses=+15552345678,+15552345679;?&body=Hello%20World">iOS multiple recipients with body</a>

Note that the body should be URI encoded.


Neither Android nor iPhones currently support the body copy element in a Tap to SMS hyperlink. It can be done programmatically though,

MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;

picker.recipients = [NSArray arrayWithObject:@"48151623"];  
picker.body = @"Body text.";

[self presentModalViewController:picker animated:YES];
[picker release];

참고URL : https://stackoverflow.com/questions/6480462/how-to-pre-populate-the-sms-body-text-via-an-html-link

반응형