cordova-plugin-reteno 1.1.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -0
- package/README.md +16 -0
- package/docs/android.md +212 -15
- package/docs/api.md +720 -6
- package/docs/ios.md +465 -38
- package/package.json +38 -43
- package/plugin.xml +32 -33
- package/scripts/android-fcm-setup.js +175 -0
- package/scripts/validate-install.js +95 -0
- package/src/android/app/build.gradle +7 -4
- package/src/android/app/src/main/AndroidManifest.xml +2 -15
- package/src/android/app/src/main/java/com/reteno/plugin/RetenoEvent.java +8 -19
- package/src/android/app/src/main/java/com/reteno/plugin/RetenoPlugin.java +2306 -91
- package/src/android/app/src/main/java/com/reteno/plugin/RetenoUserAttributes.java +120 -135
- package/src/android/app/src/main/java/com/reteno/plugin/RetenoUtil.java +51 -4
- package/src/android/reteno.gradle +81 -5
- package/src/ios/RetenoPlugin.swift +1602 -161
- package/types/index.ts +431 -0
- package/www/cordova-plugin-reteno.js +597 -40
- package/.editorconfig +0 -17
- package/.travis.yml +0 -108
- package/CODE_OF_CONDUCT.md +0 -133
- package/CONTRIBUTING.md +0 -114
- package/src/android/.idea/.name +0 -1
- package/src/android/.idea/compiler.xml +0 -6
- package/src/android/.idea/gradle.xml +0 -20
- package/src/android/.idea/misc.xml +0 -9
- package/src/android/.idea/vcs.xml +0 -6
- package/src/android/app/src/androidTest/java/com/reteno/plugin/ExampleInstrumentedTest.java +0 -26
- package/src/android/app/src/main/java/com/reteno/plugin/CordovaRetenoApplication.java +0 -6
- package/src/android/app/src/main/java/com/reteno/plugin/RetenoPushReceiver.java +0 -14
- package/src/android/app/src/main/res/drawable/ic_launcher_background.xml +0 -170
- package/src/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +0 -30
- package/src/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +0 -6
- package/src/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +0 -6
- package/src/android/app/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
- package/src/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
- package/src/android/app/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
- package/src/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
- package/src/android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
- package/src/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
- package/src/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
- package/src/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
- package/src/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
- package/src/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
- package/src/android/app/src/main/res/values/colors.xml +0 -10
- package/src/android/app/src/main/res/values/strings.xml +0 -3
- package/src/android/app/src/main/res/values/themes.xml +0 -16
- package/src/android/app/src/main/res/values-night/themes.xml +0 -16
- package/src/android/app/src/main/res/xml/backup_rules.xml +0 -13
- package/src/android/app/src/main/res/xml/data_extraction_rules.xml +0 -19
- package/src/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/src/android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/src/android/gradlew +0 -185
- package/src/android/gradlew.bat +0 -89
- package/src/ios/RetenoEvent.swift +0 -67
- package/src/ios/RetenoPlugin-Bridging-Header.h +0 -1
- package/src/ios/RetenoUserAttributes.swift +0 -150
- package/src/ios/RetenoUtils.swift +0 -12
- package/types/index.d.ts +0 -112
package/LICENSE
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
3
|
Copyright (c) 2022 Reteno
|
|
4
|
+
|
|
4
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
6
7
|
in the Software without restriction, including without limitation the rights
|
package/README.md
ADDED
package/docs/android.md
CHANGED
|
@@ -1,34 +1,231 @@
|
|
|
1
1
|
## Installation
|
|
2
2
|
|
|
3
|
+
> Requirement: `cordova-android >= 12.0.0`. Older Cordova Android platforms will refuse to install the plugin.
|
|
4
|
+
|
|
3
5
|
1. Run next command from root of your project:
|
|
4
6
|
|
|
5
7
|
```sh
|
|
6
|
-
cordova plugin add cordova-plugin-reteno
|
|
8
|
+
cordova plugin add cordova-plugin-reteno --variable SDK_ACCESS_KEY=YOUR_KEY
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Configure via config.xml (Cordova)
|
|
12
|
+
|
|
13
|
+
If you prefer to keep the access key in your Cordova app config (instead of passing `--variable` during installation), configure it as **plugin variables** in `config.xml`:
|
|
14
|
+
|
|
15
|
+
```xml
|
|
16
|
+
<widget ...>
|
|
17
|
+
<plugin name="cordova-plugin-reteno" spec="cordova-plugin-reteno">
|
|
18
|
+
<!-- Reteno SDK access key (required) -->
|
|
19
|
+
<variable name="SDK_ACCESS_KEY" value="YOUR_KEY" />
|
|
20
|
+
</plugin>
|
|
21
|
+
</widget>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Notes:
|
|
25
|
+
|
|
26
|
+
- Precedence for `SDK_ACCESS_KEY` is plugin variables (from install command or `config.xml`) → AndroidManifest meta-data injected by the plugin.
|
|
27
|
+
- Changing plugin variables often requires reinstalling the plugin or re-adding the platform:
|
|
28
|
+
- `cordova plugin rm cordova-plugin-reteno && cordova plugin add ...`
|
|
29
|
+
- or `cordova platform rm android && cordova platform add android`
|
|
30
|
+
|
|
31
|
+
2. Reteno dependency is added automatically by the plugin via its Gradle hook.
|
|
32
|
+
|
|
33
|
+
3. Android 13+ (and `targetSdkVersion >= 33`) requires notification runtime permission. The plugin injects the manifest permission (`POST_NOTIFICATIONS`), but you still must request it at runtime in your app.
|
|
34
|
+
|
|
35
|
+
You can request it via the plugin API:
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
RetenoPlugin
|
|
39
|
+
.requestNotificationPermission()
|
|
40
|
+
.then((grantedInt) => {
|
|
41
|
+
// grantedInt: 1 (granted) or 0 (declined)
|
|
42
|
+
})
|
|
43
|
+
.catch((err) => {
|
|
44
|
+
console.error(err);
|
|
45
|
+
});
|
|
7
46
|
```
|
|
8
47
|
|
|
9
|
-
|
|
48
|
+
4. SDK initialization
|
|
49
|
+
|
|
50
|
+
Initialize Reteno once during app startup:
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
RetenoPlugin
|
|
54
|
+
.init()
|
|
55
|
+
.then(() => {
|
|
56
|
+
// initialized
|
|
57
|
+
})
|
|
58
|
+
.catch((err) => {
|
|
59
|
+
console.error(err);
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
If you need advanced Reteno configuration (custom `RetenoConfig`, custom device id provider, etc), you can initialize Reteno in your custom `Application` as described here:
|
|
64
|
+
[link](https://docs.reteno.com/reference/android-sdk-setup#step-4-initialize-the-reteno-sdk).
|
|
65
|
+
|
|
66
|
+
5. Set up Firebase for Cloud Messaging (create Firebase project, add `google-services.json`, etc):
|
|
67
|
+
[link](https://docs.reteno.com/reference/setting-up-your-firebase-application-for-firebase-cloud-messaging).
|
|
68
|
+
|
|
69
|
+
## Push notification listeners
|
|
10
70
|
|
|
11
|
-
|
|
71
|
+
The plugin uses the listener-based API (`EventListener` / `Procedure`) for all push events.
|
|
12
72
|
|
|
13
|
-
|
|
73
|
+
- `setOnRetenoPushDismissedListener(listener)` — called when a push notification is dismissed (swiped away).
|
|
74
|
+
- `setOnRetenoCustomPushReceivedListener(listener)` — called when a custom push notification is received.
|
|
14
75
|
|
|
15
|
-
|
|
16
|
-
```groovy
|
|
76
|
+
Each method accepts a listener that receives a payload object. Use the corresponding `remove...` method to unsubscribe:
|
|
17
77
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
78
|
+
```js
|
|
79
|
+
const onDismissed = (payload) => {
|
|
80
|
+
console.log('Push dismissed', payload);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const onCustomReceived = (payload) => {
|
|
84
|
+
console.log('Custom push received', payload);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
RetenoPlugin.setOnRetenoPushDismissedListener(onDismissed);
|
|
88
|
+
RetenoPlugin.setOnRetenoCustomPushReceivedListener(onCustomReceived);
|
|
89
|
+
|
|
90
|
+
// later:
|
|
91
|
+
RetenoPlugin.removeOnRetenoPushDismissedListener(onDismissed);
|
|
92
|
+
RetenoPlugin.removeOnRetenoCustomPushReceivedListener(onCustomReceived);
|
|
21
93
|
```
|
|
22
94
|
|
|
23
|
-
|
|
95
|
+
### Without Firebasex (Cordova)
|
|
96
|
+
|
|
97
|
+
If you **do not need** `cordova-plugin-firebasex` features, you can still use Reteno Push on Android.
|
|
98
|
+
For FCM to work, your Cordova Android project must have:
|
|
99
|
+
|
|
100
|
+
1. `google-services.json` (from Firebase Console)
|
|
101
|
+
|
|
102
|
+
- Download it from Firebase Console → Project settings → Your apps (Android) → `google-services.json`.
|
|
103
|
+
- Put it into your Cordova project in one of these locations (the plugin will copy it into `platforms/android/app/` automatically):
|
|
104
|
+
- `<projectRoot>/google-services.json`
|
|
105
|
+
- `<projectRoot>/resources/android/google-services.json`
|
|
106
|
+
- `<projectRoot>/resources/google-services.json`
|
|
107
|
+
|
|
108
|
+
2. Google Services Gradle plugin applied (`com.google.gms.google-services`)
|
|
109
|
+
|
|
110
|
+
The plugin automatically applies Google Services Gradle plugin during `after_platform_add` and `after_prepare`.
|
|
111
|
+
|
|
112
|
+
How to verify:
|
|
113
|
+
|
|
114
|
+
- Check that `platforms/android/app/google-services.json` exists.
|
|
115
|
+
- Check `platforms/android/app/build.gradle` contains `com.google.gms.google-services`.
|
|
116
|
+
- If your Gradle build logs contain a message like “google-services.json not found, google-services plugin not applied. Push Notifications won't work”, then the plugin is NOT applied and push won’t work.
|
|
117
|
+
|
|
118
|
+
### Ionic/Capacitor note
|
|
119
|
+
|
|
120
|
+
For Capacitor apps, see the dedicated [Capacitor setup (Android)](#capacitor-setup-android) section below.
|
|
121
|
+
|
|
122
|
+
### Warning: Reteno + Firebasex (Android)
|
|
123
|
+
|
|
124
|
+
If you use `cordova-plugin-firebasex` in the same app, be aware it can register its own `FirebaseMessagingService`.
|
|
125
|
+
On Android, only one service may receive `com.google.firebase.MESSAGING_EVENT`, so Firebasex can prevent Reteno from receiving `onNewToken` / `onMessageReceived` callbacks.
|
|
126
|
+
|
|
127
|
+
Recommendation: don’t install Firebasex “just for push”. Install it only if you need its other Firebase features.
|
|
128
|
+
|
|
129
|
+
### Custom FCM service (Android)
|
|
130
|
+
|
|
131
|
+
In most Cordova apps you **do not need** a custom `FirebaseMessagingService`.
|
|
132
|
+
Only add one if you have your **own native push handling** (or another SDK that requires a custom FCM service).
|
|
133
|
+
|
|
134
|
+
If you do add a custom service, follow Reteno guidance: extend `RetenoFirebaseMessagingService` (not `FirebaseMessagingService`) and call `super` methods.
|
|
24
135
|
|
|
25
|
-
|
|
26
|
-
|
|
136
|
+
See Reteno docs:
|
|
27
137
|
|
|
28
|
-
|
|
138
|
+
- https://docs.reteno.com/reference/android-sdk-setup
|
|
139
|
+
- https://docs.reteno.com/reference/android-push-handling
|
|
140
|
+
|
|
141
|
+
## Capacitor setup (Android)
|
|
142
|
+
|
|
143
|
+
Capacitor uses Cordova plugins through a compatibility layer, but **does not execute Cordova plugin hooks**. This means several automatic steps that work in Cordova must be done manually.
|
|
144
|
+
|
|
145
|
+
### 1. Install the plugin
|
|
29
146
|
|
|
30
147
|
```sh
|
|
31
|
-
|
|
148
|
+
npm install cordova-plugin-reteno
|
|
149
|
+
npx cap sync android
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 2. Configure `SDK_ACCESS_KEY`
|
|
153
|
+
|
|
154
|
+
In `capacitor.config.ts`, pass the access key through `cordova.preferences`:
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
import { CapacitorConfig } from '@capacitor/cli';
|
|
158
|
+
|
|
159
|
+
const config: CapacitorConfig = {
|
|
160
|
+
// ...
|
|
161
|
+
cordova: {
|
|
162
|
+
preferences: {
|
|
163
|
+
SDK_ACCESS_KEY: 'YOUR_KEY',
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export default config;
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
The plugin's `reteno.gradle` script automatically reads this value from `capacitor.config.json` (generated by Capacitor CLI) and patches the Android manifest at build time. No manual manifest editing is required.
|
|
172
|
+
|
|
173
|
+
You can also pass the key explicitly in JS:
|
|
174
|
+
|
|
175
|
+
```js
|
|
176
|
+
await RetenoPlugin.init({ accessKey: 'YOUR_KEY' });
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### 3. Set up `google-services.json`
|
|
180
|
+
|
|
181
|
+
The Cordova hook that auto-copies `google-services.json` does **not** run in Capacitor.
|
|
182
|
+
|
|
183
|
+
Do this manually:
|
|
184
|
+
|
|
185
|
+
1. Download `google-services.json` from [Firebase Console](https://console.firebase.google.com/).
|
|
186
|
+
2. Copy it to `android/app/google-services.json`.
|
|
187
|
+
3. Run `npx cap sync android`.
|
|
188
|
+
|
|
189
|
+
### 4. Google Services Gradle plugin
|
|
190
|
+
|
|
191
|
+
In Capacitor projects, the Google Services Gradle plugin is typically already applied if you use any Firebase dependency. Verify that `android/app/build.gradle` contains:
|
|
192
|
+
|
|
193
|
+
```gradle
|
|
194
|
+
apply plugin: 'com.google.gms.google-services'
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
If not, add it manually or install `@capacitor-firebase/messaging` (or similar) which applies it automatically.
|
|
198
|
+
|
|
199
|
+
### 5. Initialize the SDK
|
|
200
|
+
|
|
201
|
+
```js
|
|
202
|
+
await RetenoPlugin.init();
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### 6. Request notification permission
|
|
206
|
+
|
|
207
|
+
Same as Cordova — call at the appropriate point in your UX:
|
|
208
|
+
|
|
209
|
+
```js
|
|
210
|
+
const granted = await RetenoPlugin.requestNotificationPermission();
|
|
32
211
|
```
|
|
33
212
|
|
|
34
|
-
|
|
213
|
+
### Deeplinks in push payloads
|
|
214
|
+
|
|
215
|
+
Reteno push notifications on Android can include deeplinks.
|
|
216
|
+
|
|
217
|
+
In a native Android app, you can usually route those links with your own `Intent` handling, Android App Links, or custom URL schemes.
|
|
218
|
+
|
|
219
|
+
For Cordova/Ionic/Capacitor apps, deeplink routing usually requires a separate app-level solution. This plugin does not provide a full deeplink router by itself, so if you need custom navigation from push links, use a dedicated deeplink integration, for example:
|
|
220
|
+
|
|
221
|
+
- Branch.io
|
|
222
|
+
- a custom URL scheme plugin
|
|
223
|
+
- an Android App Links / Universal Links plugin
|
|
224
|
+
|
|
225
|
+
Typical setup for hybrid apps:
|
|
226
|
+
|
|
227
|
+
1. Configure your app to support the required link type (custom scheme or Android App Links).
|
|
228
|
+
2. Install and configure your deeplink provider/router (for example, Branch.io) in the app project.
|
|
229
|
+
3. Route the tapped push link into that provider/router so the app opens the correct webview route or native screen.
|
|
230
|
+
|
|
231
|
+
In practice, Reteno can deliver the link in the push payload, but opening the correct destination inside a hybrid app is still handled by your deeplink integration layer.
|