This repository has been archived by the owner on Apr 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdevelopment_javascript_Messaging.html
173 lines (135 loc) · 4.36 KB
/
development_javascript_Messaging.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mobile Widgets</title>
<link rel="stylesheet" href="style/style.css" />
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<script type="text/javascript" src="js/StructureElts.js"></script>
<script type="text/javascript" src="js/Structure.js"></script>
<script type="text/javascript" src="js/DocElements.js"></script>
</head>
<body>
<script type="text/javascript">
<!--
idCurrentPage = "development_javascript_Messaging";
beginPage();
//-->
</script>
<h1 class="title">Messaging Javascript library</h1>
<script type="text/javascript">
<!--
addIndex();
//-->
</script>
<script type="text/javascript">addTitle("Description", 1);</script>
<p>
The Messaging class provides means to send an SMS or an MMS with a picture.
</p>
<br/>
<script type="text/javascript">addTitle("Since", 1);</script>
<h2>1.4.8</h2>
<p>
New methods: <b>startListeningSMS()</b>, <b>stopListeningSMS()</b>, <b>isPushSMSAvailable ()</b>, <b>registerPushSMS ()</b>, <b>unregisterPushSMS ()</b> and <b>isRegisteredPushSMS()</b>.<br/>
</p>
<br/>
<script type="text/javascript">addTitle("Methods", 1);</script>
<p>
<b>bool isAvailable ()</b>:<br/>
Returns True if mobile sending SMS and MMS is supported.
</p>
<p>
<b>bool sendSMS (String phoneNumber, String message)</b>:<br/>
Send a SMS. Returns true if successful, false on error.
</p>
<p>
<b>bool sendMMS (String phoneNumber, String subject, String message, String imageUrl)</b>:<br/>
Send a MMS.
</p>
<p>
<b>bool startListeningSMS (int port, String messageName)</b>:<br/>
Waiting for incoming SMS on specified port through a Message node with url "messageName". The data_changed MFString field of the message node will be update as follow:
<ul>
<li>data_changed [0] : sender phone number</li>
<li>data_changed [1] : reception port number</li>
<li>data_changed [2] : content of the SMS</li>
</ul>
<b>Since 1.4.8</b>
</p>
<p>
<b>bool stopListeningSMS (int port)</b>:<br/>
Stop waiting for incoming SMS on specified port.
</p>
<p>
<b>bool isPushSMSAvailable ()</b>:<br/>
Check if memo player supports push SMS
</p>
<p>
<b>bool registerPushSMS (int port)</b>:<br/>
Register a port to wake up midlet on incoming SMS on specified port.
</p>
<p>
<b>bool unregisterPushSMS (int port)</b>:<br/>
Register previously registered port.
</p>
<p>
<b>bool isRegisteredPushSMS (int port)</b>:<br/>
Check if specified port is already registered.
</p>
<br/>
<script type="text/javascript">addTitle("Example", 1);</script>
<h2>Example sending SMS</h2>
<textarea wrap="off" readonly="readonly" rows="15" cols="80">
function test(phoneNumber, SMSContent) {
//SMSContent = String.URLdecode(SMSContent); //check that no special character is send in SMS content
if (Messaging.isAvailable()) {
var resp = Messaging.sendSMS(phoneNumber, SMSContent); //phoneNumber example: +33123456789
if (resp == 1) {
Browser.print('SMS was sent');
}
else {
Browser.print('Error occured while sending SMS, resp = '+resp+', phone = '+phoneNumber+', SMSContent = '+phoneNumber);
}
}
else {
Browser.print('Error occured while sending SMS');
}
}
</textarea>
<br/>
<h2>Example waiting incoming SMS</h2>
<textarea wrap="off" readonly="readonly" rows="15" cols="80">
DEF MSG_SMS Message { url "MY_SMS" }
...
DEF SCRIPT Script {
eventIn MFString smsHandler
...
function initialize () {
if( Messaging.startListeningSMS(1000,'MY_SMS') == true ) {
Browser.print('started listening SMS on port 1000');
}
}
function smsHandler () {
var from = smsHandler[0];
var port = smsHandler[1];
var content = smsHandler[2];
Browser.print('received SMS: '+content+' , from: '+from+' on port: '+port);
}
}
ROUTE MSG_SMS.data_changed TO SCRIPT.smsHandler
</textarea>
<br/>
<script type="text/javascript">
<!--
addBackPageNavigator('widgets_development_javascript_ref', '');
//-->
</script>
<script type="text/javascript">
<!--
endPage();
//-->
</script>
</body>
</html>