Skip to content

Commit aa41653

Browse files
committed
Merge branch 'main' into MOB-11360-remove-apikey
2 parents b4c1600 + ad4568b commit aa41653

File tree

10 files changed

+76
-49
lines changed

10 files changed

+76
-49
lines changed

README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ the native code is generated through `expo prebuild`.
2424
- [Troubleshooting](#troubleshooting)
2525
- [Native Module Not Found](#native-module-not-found)
2626
- [Failed to delete [ios|android] code: ENOTEMPTY: directory not empty](#failed-to-delete-iosandroid-code-enotempty-directory-not-empty)
27+
- [Contributing](#contributing)
2728
- [License](#license)
29+
- [Support](#support)
2830
- [Further Reading](#further-reading)
2931

3032
<!-- /code_chunk_output -->
@@ -86,7 +88,6 @@ Add the plugin to your `app.json` or `app.config.js`:
8688
"autoConfigurePushNotifications": true,
8789
"enableTimeSensitivePush": true,
8890
"requestPermissionsForPushNotifications": true,
89-
"enableInAppMessages": true
9091
}]
9192
]
9293
}
@@ -97,12 +98,11 @@ Add the plugin to your `app.json` or `app.config.js`:
9798
9899
| Option | Type | Default | Description |
99100
|--------|------|---------|-------------|
100-
| `apiKey` | string | - | Your Iterable API key |
101-
| `appEnvironment` | 'development' \| 'production' | 'development' | The environment for your app |
102-
| `autoConfigurePushNotifications` | boolean | true | Whether to automatically configure push notifications |
103-
| `enableTimeSensitivePush` | boolean | true | Whether to enable time-sensitive push notifications (ios only) |
104-
| `requestPermissionsForPushNotifications` | boolean | true | Whether to request permissions for push notifications (ios only) |
105-
| `enableInAppMessages` | boolean | true | Whether to enable in-app messages |
101+
| `apiKey` | string | `''` | Your Iterable project API key |
102+
| `appEnvironment` | `'development'` \| `'production'` | `'development'` | The environment of your app |
103+
| `autoConfigurePushNotifications` | boolean | `true` | Whether to automatically configure push notifications. Set to `false` if you want to configure push notifications manually. <br><br> **WARNING**: Iterable cannot guarantee compatibility with custom push notification configurations. |
104+
| `enableTimeSensitivePush` | boolean | `true` | Whether to enable time-sensitive push notifications (iOS only) |
105+
| `requestPermissionsForPushNotifications` | boolean | `false` | Whether to request permissions for push notifications (iOS only) |
106106
107107
### Disabling New Architecture
108108
`@iterable/react-native-sdk` is *NOT* compatible with Reacts New Architecture,
@@ -118,7 +118,7 @@ so this needs to be disabled in your `app.json`:
118118
119119
### Adding push capabilities to android
120120
121-
Add the path to your google-services.json file to the app file under
121+
Add the path to your google-services.json file to the app.json file under
122122
`expo.android.googleServicesFile`. EG: If the google services file was added to
123123
the root of the app, the expo file would look like this:
124124
```json
@@ -315,9 +315,21 @@ Sometimes this error appears when running `npx expo prebuild --clean`. It seems
315315
to be an intermittent bug within expo. It usually works upon running the same
316316
command a second time, so just try again.
317317
318+
## Contributing
319+
320+
Contributions are welcome! Please feel free to submit a Pull Request.
321+
318322
## License
319323
320-
MIT
324+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
325+
for details.
326+
327+
## Support
328+
329+
For support, please:
330+
1. Check the [documentation](https://github.com/Iterable/iterable-expo-plugin#readme)
331+
2. Open an [issue](https://github.com/Iterable/iterable-expo-plugin/issues)
332+
3. Contact [Iterable support](https://support.iterable.com/hc/en-us/requests/new)
321333
322334
## Further Reading
323335
- [Installing Iterables React Native

example/app.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
{
7070
"appEnvironment": "development",
7171
"autoConfigurePushNotifications": true,
72-
"enableInAppMessages": true,
7372
"enableTimeSensitivePush": true,
7473
"requestPermissionsForPushNotifications": true
7574
}

ios/ExpoAdapterIterable/IterableAppDelegate.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,10 @@ public class IterableAppDelegate: ExpoAppDelegateSubscriber, UIApplicationDelega
3535
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void
3636
) {
3737

38-
if Bundle.main.object(
39-
forInfoDictionaryKey: "ITERABLE_ENABLE_IN_APP_MESSAGES") as? Bool == true
40-
{
41-
IterableAppIntegration.application(
42-
application, didReceiveRemoteNotification: userInfo,
43-
fetchCompletionHandler: completionHandler
44-
)
45-
}
38+
IterableAppIntegration.application(
39+
application, didReceiveRemoteNotification: userInfo,
40+
fetchCompletionHandler: completionHandler
41+
)
4642
}
4743

4844
public func application(

plugin/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const withIterable: ConfigPlugin<ConfigPluginProps> = (config, props = {}) => {
1818
enableTimeSensitivePush: props.enableTimeSensitivePush ?? true,
1919
requestPermissionsForPushNotifications:
2020
props.requestPermissionsForPushNotifications ?? false,
21-
enableInAppMessages: props.enableInAppMessages ?? true,
2221
};
2322

2423
return withPlugins(config, [

plugin/src/withIterable.types.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,31 @@ export interface ConfigPluginProps {
66
appEnvironment?: 'development' | 'production';
77
/**
88
* Whether to automatically configure push notifications.
9+
*
10+
* If true, this will set up the necessary permissions and configurations for
11+
* push notifications according to the Iterable SDK documentation. If you
12+
* would like to build your own push notification configuration, set this to
13+
* false -- but do so with caution as Iterable cannot guarantee compatibility
14+
* with custom push notification configurations.
915
* @default true
1016
*/
1117
autoConfigurePushNotifications?: boolean;
1218
/**
1319
* Whether to enable time-sensitive push notifications.
20+
*
21+
* (iOS only)
22+
*
1423
* @default true
1524
*/
1625
enableTimeSensitivePush?: boolean;
1726
/**
1827
* Whether to request permissions for push notifications.
28+
*
29+
* (iOS only)
30+
*
1931
* @default false
2032
*/
2133
requestPermissionsForPushNotifications?: boolean;
22-
/**
23-
* Whether to enable in-app messages.
24-
* @default true
25-
*/
26-
enableInAppMessages?: boolean;
2734
}
2835

2936
export type ConfigPluginPropsWithDefaults = Required<ConfigPluginProps>;

plugin/src/withPushNotifications/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ import { withIosPushNotifications } from './withIosPushNotifications';
77
export const withPushNotifications: ConfigPlugin<
88
ConfigPluginPropsWithDefaults
99
> = (config, props) => {
10+
/**
11+
* No need to do anything if `props.autoConfigurePushNotifications` is
12+
* explicitly set to `false`.
13+
*/
14+
if (props.autoConfigurePushNotifications === false) {
15+
return config;
16+
}
17+
1018
return withPlugins(config, [
1119
[withIosPushNotifications, props],
1220
[withAndroidPushNotifications, props],

plugin/src/withPushNotifications/withAndroidPushNotifications.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
ConfigPlugin,
33
WarningAggregator,
4+
withAndroidManifest,
45
withAppBuildGradle,
56
withDangerousMod,
67
withPlugins,
@@ -166,6 +167,33 @@ const withFirebase: ConfigPlugin<ConfigPluginPropsWithDefaults> = (
166167
]);
167168
};
168169

170+
/**
171+
* Add the POST_NOTIFICATIONS permission to the AndroidManifest.xml file if it
172+
* doesn't exist.
173+
*/
174+
const withAppPermissions: ConfigPlugin<ConfigPluginPropsWithDefaults> = (
175+
config
176+
) => {
177+
return withAndroidManifest(config, (newConfig) => {
178+
const androidManifest = newConfig.modResults.manifest;
179+
if (!androidManifest['uses-permission']) {
180+
androidManifest['uses-permission'] = [];
181+
}
182+
const postPermission = 'android.permission.POST_NOTIFICATIONS';
183+
const currPostPermission = androidManifest['uses-permission'].find(
184+
(p) => p.$['android:name'] === postPermission
185+
);
186+
187+
// Only add the permission if it doesn't exist
188+
if (!currPostPermission) {
189+
androidManifest['uses-permission'].push({
190+
$: { 'android:name': postPermission },
191+
});
192+
}
193+
return newConfig;
194+
});
195+
};
196+
169197
/**
170198
* Copy `google-services.json`
171199
* TODO: Add this step to the docs
@@ -212,6 +240,7 @@ export const withAndroidPushNotifications: ConfigPlugin<
212240
return config;
213241
}
214242
return withPlugins(config, [
243+
[withAppPermissions, props],
215244
[withFirebase, props],
216245
[withCopyAndroidGoogleServices, props],
217246
]);

plugin/src/withPushNotifications/withIosPushNotifications.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -294,14 +294,6 @@ end`;
294294
export const withIosPushNotifications: ConfigPlugin<
295295
ConfigPluginPropsWithDefaults
296296
> = (config, props) => {
297-
/**
298-
* No need to do anything if `props.autoConfigurePushNotifications` is
299-
* explicitly set to `false`.
300-
*/
301-
if (props.autoConfigurePushNotifications === false) {
302-
return config;
303-
}
304-
305297
return withPlugins(config, [
306298
[withCapabilities, props],
307299
[withBackgroundModes, props],

plugin/src/withStoreConfigValues.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { type ConfigPluginPropsWithDefaults } from './withIterable.types';
1515
*/
1616
type JsKey = keyof Pick<
1717
ConfigPluginPropsWithDefaults,
18-
'requestPermissionsForPushNotifications' | 'enableInAppMessages'
18+
'requestPermissionsForPushNotifications'
1919
>;
2020

2121
/**
@@ -34,7 +34,6 @@ type NativeKey = string;
3434
const nativeKeyMap: Record<JsKey, NativeKey> = {
3535
requestPermissionsForPushNotifications:
3636
'ITERABLE_REQUEST_PERMISSIONS_FOR_PUSH_NOTIFICATIONS',
37-
enableInAppMessages: 'ITERABLE_ENABLE_IN_APP_MESSAGES',
3837
};
3938

4039
const withStoreValuesOnIos: ConfigPlugin<ConfigPluginPropsWithDefaults> = (

plugin/tsconfig.tsbuildinfo

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1 @@
1-
{
2-
"root": [
3-
"./src/index.ts",
4-
"./src/withdeeplinks.ts",
5-
"./src/withiterable.types.ts",
6-
"./src/withiterableapis.ts",
7-
"./src/withstoreconfigvalues.ts",
8-
"./src/withpushnotifications/index.ts",
9-
"./src/withpushnotifications/withandroidpushnotifications.constants.ts",
10-
"./src/withpushnotifications/withandroidpushnotifications.ts",
11-
"./src/withpushnotifications/withiospushnotifications.constants.ts",
12-
"./src/withpushnotifications/withiospushnotifications.ts"
13-
],
14-
"version": "5.8.3"
15-
}
1+
{"root":["./src/index.ts","./src/withdeeplinks.ts","./src/withiterable.types.ts","./src/withstoreconfigvalues.ts","./src/withpushnotifications/index.ts","./src/withpushnotifications/withandroidpushnotifications.constants.ts","./src/withpushnotifications/withandroidpushnotifications.ts","./src/withpushnotifications/withiospushnotifications.constants.ts","./src/withpushnotifications/withiospushnotifications.ts"],"version":"5.8.3"}

0 commit comments

Comments
 (0)