cordova-plugin-sms-retriever-manager 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "cordova-plugin-sms-retriever-manager",
|
3
|
-
"version": "1.0.
|
4
|
-
"description": "
|
3
|
+
"version": "1.0.4",
|
4
|
+
"description": "Easily retrieve SMS messages using the Google SMS Retriever API with our cross-platform plugin designed for Ionic/Cordova. This powerful tool streamlines the process and is specifically available for Android devices.",
|
5
5
|
"cordova": {
|
6
6
|
"id": "cordova-plugin-sms-retriever-manager",
|
7
7
|
"platforms": [
|
@@ -26,7 +26,7 @@
|
|
26
26
|
}
|
27
27
|
],
|
28
28
|
"author": "Haresh Hanat",
|
29
|
-
"license": "
|
29
|
+
"license": "MIT",
|
30
30
|
"bugs": {
|
31
31
|
"url": "https://github.com/hanatharesh2712/ionic-native-sms-retriever-plugin-master/issues"
|
32
32
|
},
|
package/plugin.xml
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
3
|
-
id="cordova-plugin-sms-retriever-manager" version="1.0.
|
4
|
-
<name>
|
5
|
-
<description>
|
3
|
+
id="cordova-plugin-sms-retriever-manager" version="1.0.4">
|
4
|
+
<name>Cordova SMS Retriver Plugin</name>
|
5
|
+
<description>Easily retrieve SMS messages using the Google SMS Retriever API with our cross-platform plugin designed for Ionic/Cordova. This powerful tool streamlines the process and is specifically available for Android devices.</description>
|
6
6
|
<license>MIT</license>
|
7
7
|
<keywords>ionic, ionic3, cordova, cordova-plugin, phonegap-plugin, ionic-framework, ionic-cordova, sms, sms-verificationm automatic SMS receive</keywords>
|
8
8
|
|
package/readme.md
CHANGED
@@ -29,62 +29,58 @@ HTML
|
|
29
29
|
Javascript
|
30
30
|
|
31
31
|
```js
|
32
|
-
|
33
32
|
document.querySelector('.hashCode').addEventListener('click', this.getAppHash);
|
34
33
|
document.querySelector('.startWatching').addEventListener('click', this.retriveSMS);
|
35
34
|
|
36
35
|
var app = {
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
36
|
+
getAppHash: function() {
|
37
|
+
window['cordova']['plugins']['smsRetriever']['getAppHash'](
|
38
|
+
(result) => {
|
39
|
+
// Once you get this hash code of your app. Please remove this code.
|
40
|
+
alert(result);
|
41
|
+
console.log('Hash', result);
|
42
|
+
},
|
43
|
+
(err) => {
|
44
|
+
console.log(err);
|
45
|
+
});
|
46
|
+
},
|
47
|
+
|
48
|
+
retriveSMS: function() {
|
49
|
+
window['cordova']['plugins']['smsRetriever']['startWatching'](
|
50
|
+
// the first callback is the success callback. We got back the native code’s result here.
|
51
|
+
(result) => {
|
52
|
+
alert(result.Message);
|
53
|
+
console.log('Message', result);
|
54
|
+
},
|
55
|
+
// the second is the error callback where we get back the errors
|
56
|
+
(err) => {
|
57
|
+
console.log(err);
|
58
|
+
});
|
59
|
+
}
|
61
60
|
};
|
62
61
|
```
|
63
62
|
You can find working Demo for Ionic 4 here: https://github.com/hanatharesh2712/sms-plugin-test
|
64
63
|
|
65
64
|
Typescript (Ionic 4)
|
66
65
|
```typescript
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
constructor(private smsRetriever: SmsRetriever) { }
|
71
|
-
|
72
|
-
...
|
73
|
-
|
74
|
-
// This function is to get hash string of APP.
|
75
|
-
// * @return {Promise<string>} Returns a promise that resolves when successfully generate hash of APP.
|
76
|
-
this.smsRetriever.getAppHash()
|
77
|
-
.then((res: any) => console.log(res))
|
78
|
-
.catch((error: any) => console.error(error));
|
66
|
+
import { SmsRetriever } from '@ionic-native/sms-retriever/ngx';
|
79
67
|
|
68
|
+
constructor(private smsRetriever: SmsRetriever) { }
|
69
|
+
|
70
|
+
...
|
71
|
+
|
72
|
+
// This function is to get hash string of APP.
|
73
|
+
// * @return {Promise<string>} Returns a promise that resolves when successfully generate hash of APP.
|
74
|
+
this.smsRetriever.getAppHash()
|
75
|
+
.then((res: any) => console.log(res))
|
76
|
+
.catch((error: any) => console.error(error));
|
80
77
|
|
81
78
|
// * This function start wathching message arrive event and retrive message text.
|
82
79
|
// * @return {Promise<string>} Returns a promise that resolves when retrives SMS text or TIMEOUT after 5 min.
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
```
|
80
|
+
this.smsRetriever.startWatching()
|
81
|
+
.then((res: any) => console.log(res))
|
82
|
+
.catch((error: any) => console.error(error));
|
83
|
+
```
|
88
84
|
|
89
85
|
You can find working Demo for Ionic 3 here: https://github.com/hanatharesh2712/sms-plugin-test-ionic-3
|
90
86
|
|
@@ -93,37 +89,38 @@ You can find working Demo for Ionic 3 here: https://github.com/hanatharesh2712/s
|
|
93
89
|
|
94
90
|
import { SmsRetriever } from '@ionic-native/sms-retriever/ngx';
|
95
91
|
var smsRetriever = window['cordova']['plugins']['smsRetriever'];
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
92
|
+
|
93
|
+
public smsTextmessage: string = '';
|
94
|
+
public appHashString: string = '';
|
95
|
+
constructor(private smsRetriever: SmsRetriever) { }
|
96
|
+
|
97
|
+
...
|
98
|
+
|
99
|
+
getHashCode() {
|
100
|
+
smsRetriever['getAppHash'](
|
101
|
+
(res) => {
|
105
102
|
this.appHashString = res;
|
106
103
|
console.log(res);
|
107
104
|
}, (err) => {
|
108
105
|
console.warn(err);
|
109
106
|
}
|
110
|
-
|
111
|
-
|
107
|
+
);
|
108
|
+
}
|
112
109
|
|
113
|
-
|
114
|
-
|
110
|
+
getSMS() {
|
111
|
+
smsRetriever['startWatching'](
|
112
|
+
(res) => {
|
115
113
|
this.smsTextmessage = res.Message;
|
116
114
|
console.log(res);
|
117
115
|
}, (err) => {
|
118
116
|
console.warn(err);
|
119
117
|
}
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
Flow to test:
|
124
|
-
[![flow](https://raw.githubusercontent.com/hanatharesh2712/automatic-sms-cordova/main/hello/res/ref-images/sms%20plugin%20demo.png)](https://raw.githubusercontent.com/hanatharesh2712/automatic-sms-cordova/main/hello/res/ref-images/sms%20plugin%20demo.png)
|
118
|
+
);
|
119
|
+
}
|
120
|
+
```
|
125
121
|
|
126
|
-
|
122
|
+
Flow to test:
|
123
|
+
[![flow](https://raw.githubusercontent.com/hanatharesh2712/automatic-sms-cordova/main/hello/res/ref-images/sms%20plugin%20demo.png)](https://raw.githubusercontent.com/hanatharesh2712/automatic-sms-cordova/main/hello/res/ref-images/sms%20plugin%20demo.png)
|
127
124
|
|
128
125
|
You need to send your application hash in SMS when you are sending from your backend. to generate the hash of your application read this: https://developers.google.com/identity/sms-retriever/verify
|
129
126
|
|
@@ -132,9 +129,6 @@ To get your application hash code:
|
|
132
129
|
* Without the correct hash, your app won't recieve the message callback. This only needs to be
|
133
130
|
* generated once per app and stored. Then you can remove this function from your code.
|
134
131
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
132
|
BUILD FAILED
|
139
133
|
|
140
134
|
The problem is that you need to make sure that you set the target to android-19 or later in your ./platforms/android/project.properties file like this:
|
@@ -208,7 +208,8 @@ public class AndroidSmsRetriever extends CordovaPlugin {
|
|
208
208
|
case CommonStatusCodes.SUCCESS:
|
209
209
|
final String message = extra.getString(SmsRetriever.EXTRA_SMS_MESSAGE);
|
210
210
|
//if (!StringUtils.hasContent(message)) return;
|
211
|
-
|
211
|
+
if(message == null) return;
|
212
|
+
|
212
213
|
Log.d(TAG, message);
|
213
214
|
|
214
215
|
data = new JSONObject();
|
@@ -231,4 +232,4 @@ public class AndroidSmsRetriever extends CordovaPlugin {
|
|
231
232
|
}
|
232
233
|
};
|
233
234
|
};
|
234
|
-
}
|
235
|
+
}
|