-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
```jsx | ||
window.location.href = sms:?body=${encodeURIComponent("hi")}; | ||
|
||
``` | ||
**`window.location.href`** | ||
- 현재 웹사이트의 URL 변경 | ||
**`sms:?body=${encodeURIComponent("hi")}`** | ||
- SMS URL 구성 | ||
- sms: | ||
- URL 스키마 | ||
- body: | ||
- 메시지 본문 지정 매개 변수 | ||
**`encodeURIComponent("hi")`** | ||
- 메시지 본문의 텍스트 “hi” 인코딩 | ||
- 예시엔 특수문자가 없기 때문에 sms?body=hi와 같이 평가되지만 실제 사용에서는 그렇지 않기 떄문에 **`encodeURIComponent` 필요** | ||
### 실제 사용 예시 | ||
[[ FEAT ] 문자메시지로 공유하기 기능 추가 ](https://github.com/Gwasuwon-shot/Tutice_Client/pull/470) | ||
```jsx | ||
function handleShareViaMessage() { | ||
const message = `안녕하세요, 과외 수업 관리 필수 앱 Tutice 입니다. \n\n[${userName}]선생님이 [${studentName}]학생의\nTutice 초대장을 보냈습니다.\n\nTutice 링크 \n ${URL}`; | ||
const smsLink = `sms:?body=${encodeURIComponent(message)}`; | ||
window.location.href = smsLink; | ||
} | ||
``` |