Skip to content

Commit 3c2b03b

Browse files
committed
Add sms email form readme
1 parent a342937 commit 3c2b03b

File tree

3 files changed

+33
-15
lines changed

3 files changed

+33
-15
lines changed

sms_email_form/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# SMS + Email Form Template
2+
3+
This HTML template will let you request email addresses and phone numbers from users and create new SMS and Email players out of them. You will need to add your Onesignal App ID into this template at the appropriate place.
4+
5+
###### SMS Email form on Android
6+
![Screenshot](assets/sms_email_form.png)
7+
8+
## Safe Area (notch) Detection
9+
Certain mobile devices may have safe areas where operating system icons or a camera notch might exist. Our Onesignal SDK detects these areas and exposes them to the iam's HTML document via `safe-area-inset-*` CSS variables :point_down:
10+
11+
https://github.com/OneSignalDevelopers/iam-html-templates/blob/00e30f0240e22f2e72ae807ac9274c3d0ab97bc8/sms_email_form/index.html#L21-L31
12+
13+
## E.164-formatted Phone Numbers
14+
Our REST API requires [E.164-formatted phone numbers](https://support.twilio.com/hc/en-us/articles/223183008-Formatting-International-Phone-Numbers). To make this easier we are using the [intl-tel-input](https://github.com/jackocnr/intl-tel-input) library.
161 KB
Loading

sms_email_form/index.html

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@
1717
href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"
1818
rel="stylesheet"
1919
/>
20-
<!--
21-
intl-tel-input
22-
for more information see https://www.twilio.com/blog/international-phone-number-input-html-javascript
23-
-->
24-
<link
25-
rel="stylesheet"
26-
href="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/css/intlTelInput.css"
27-
/>
28-
<script src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/intlTelInput.min.js"></script>
2920
<style>
3021
body {
3122
margin: 0;
@@ -148,6 +139,18 @@
148139
left: calc(50% - 131px / 2);
149140
}
150141
</style>
142+
<!--
143+
intl-tel-input
144+
for more information see https://www.twilio.com/blog/international-phone-number-input-html-javascript
145+
-->
146+
<link
147+
rel="stylesheet"
148+
href="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/css/intlTelInput.css"
149+
/>
150+
<script
151+
src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/intlTelInput.min.js"
152+
async
153+
></script>
151154
</head>
152155
<body>
153156
<div class="center-modal">
@@ -208,6 +211,8 @@ <h1>Don't miss out</h1>
208211
</form>
209212
</div>
210213
<script>
214+
var ONESIGNAL_PLAYER_API_URL = "https://onesignal.com/api/v1/players";
215+
var ONESIGNAL_APP_ID = "00000000-0000-0000-0000-000000000000"; // Replace you own app-id here
211216
// See documetation on creating a new player:
212217
// https://documentation.onesignal.com/reference/add-a-device
213218
function createEmailPlayer(emailAddress) {
@@ -218,31 +223,30 @@ <h1>Don't miss out</h1>
218223
"Content-Type": "application/json",
219224
},
220225
body: JSON.stringify({
221-
app_id: "00000000-0000-0000-0000-000000000000", // Replace you own app-id here
226+
app_id: ONESIGNAL_APP_ID,
222227
device_type: 11,
223228
identifier: emailAddress,
224229
}),
225230
};
226-
fetch("https://onesignal.com/api/v1/players", emailOptions)
231+
fetch(ONESIGNAL_PLAYER_API_URL, emailOptions)
227232
.then((response) => response.json())
228233
.then((response) => console.log(response))
229234
.catch((err) => console.error(err));
230235
}
231236
function createSmsPlayer(phoneNumber) {
232-
debugger;
233237
var smsOptions = {
234238
method: "POST",
235239
headers: {
236240
Accept: "application/json",
237241
"Content-Type": "application/json",
238242
},
239243
body: JSON.stringify({
240-
app_id: "00000000-0000-0000-0000-000000000000", // Replace you own app-id here
244+
app_id: ONESIGNAL_APP_ID,
241245
device_type: 14,
242246
identifier: phoneNumber,
243247
}),
244248
};
245-
fetch("https://onesignal.com/api/v1/players", smsOptions)
249+
fetch(ONESIGNAL_PLAYER_API_URL, smsOptions)
246250
.then((response) => response.json())
247251
.then((response) => console.log(response))
248252
.catch((err) => console.error(err));
@@ -279,7 +283,7 @@ <h1>Don't miss out</h1>
279283
return false;
280284
});
281285

282-
// Your code here
286+
// Your code here
283287
});
284288
</script>
285289
</body>

0 commit comments

Comments
 (0)