Skip to content
This repository was archived by the owner on Jul 28, 2022. It is now read-only.

Commit f4301ea

Browse files
committed
Disable do not disturb mode by default
(although it is recommended to enable it for most apps)
1 parent 22745ad commit f4301ea

File tree

3 files changed

+45
-39
lines changed

3 files changed

+45
-39
lines changed

README.md

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,48 @@ If you don't use CocoaPods, you can integrate Batch SDK manually.
4444
| `>= 0.60.0` | - auto-linking is supported |
4545
| `< 0.60.0` | - From the root folder <br/> - Run `react-native link @bam.tech/react-native-batch` |
4646

47-
### 4. Extra steps on Android
47+
### 4. Configure do not disturb mode for mobile landings/in app messages
48+
49+
Mobile landings/in app messages are modals that open in your app after being triggered by a push notification or an event.
50+
By default, they appear as soon as they are triggered, meaning that such a message can appear when your app is not yet ready. (JS code not loaded, or your navigation is not yet mounted, or any other logic that you implemented)
51+
This can raise problems, for example if one of the buttons in the in app message should redirect somewhere in your app, if the navigation is not yet ready, it won't work.
52+
Batch has a "do not disturb" mode that can delay those messages until you indicate that your app is ready.
53+
Do not disturb mode has no impact on push notifications, only on mobile landings/in app messages.
54+
55+
If you have a typical React Native app (eg. no brownfield), you should enable do not disturb mode.
56+
In the future, we might enable do not disturb mode by default, but currently we don't, in order to have the same default behavior as full native apps.
57+
58+
You can enable do not disturb mode with the following steps:
59+
60+
* On Android, add in your resources:
61+
62+
```groovy
63+
// android/app/build.gradle
64+
65+
defaultConfig {
66+
...
67+
resValue "bool", "BATCH_DISABLE_DO_NOT_DISTURB", "false"
68+
}
69+
```
70+
71+
* On iOS, add in your `Info.plist`:
72+
73+
```xml
74+
<key>BatchDisableDoNotDisturb</key>
75+
<false/>
76+
```
77+
78+
* Show pending in app message or mobile landing
79+
80+
When your app is ready to be interacted with (for example, after showing the splashscreen or preparing your navigation), disable do not disturb and show the pending in app message or mobile landing:
81+
82+
```js
83+
import { BatchMessaging } from '@bam.tech/react-native-batch';
84+
85+
await BatchMessaging.disableDoNotDisturbAndShowPendingMessage();
86+
```
87+
88+
### 5. Extra steps on Android
4889

4990
#### a. Install Batch dependencies
5091

@@ -127,7 +168,7 @@ public void onNewIntent(Intent intent)
127168
}
128169
```
129170

130-
### 5. Extra steps on iOS
171+
### 6. Extra steps on iOS
131172

132173
#### a. Enable Push Capabilities
133174

@@ -181,18 +222,6 @@ import { BatchPush } from '@bam.tech/react-native-batch';
181222
BatchPush.registerForRemoteNotifications();
182223
```
183224

184-
### Show pending in app message or mobile landing
185-
186-
When your app is ready to be interacted with (for example, after showing the splashscreen or preparing your navigation), show the pending in app message or mobile landing:
187-
188-
```js
189-
import { BatchMessaging } from '@bam.tech/react-native-batch';
190-
191-
await BatchMessaging.disableDoNotDisturbAndShowPendingMessage();
192-
```
193-
194-
**NB:** Batch's Do Not Disturb mode is enabled by default in React Native because your JS app might not be loaded when the user interacts with it. This could lead to problems when a button should redirect inside your JS app. You can disable this behaviour (see below).
195-
196225
<hr>
197226

198227
## Other
@@ -282,29 +311,6 @@ Because of this, you have to make sure to call this method only once in the app
282311

283312
Make sure to also listen for the Linking `url` event in case Batch opens your deep-link after you call getInitialURL.
284313

285-
### Disable do not disturb
286-
287-
If you want to disable do not disturb (if you have a brownfield app for example):
288-
289-
* On Android, add in your resources:
290-
291-
```groovy
292-
// android/app/build.gradle
293-
294-
defaultConfig {
295-
...
296-
resValue "bool", "BATCH_DISABLE_DO_NOT_DISTURB", "true"
297-
}
298-
```
299-
300-
* On iOS, add in your `Info.plist`:
301-
302-
```xml
303-
<key>BatchDisableDoNotDisturb</key>
304-
<true/>
305-
```
306-
307-
308314
<hr>
309315

310316
## Troubleshooting

android/src/main/java/tech/bam/RNBatchPush/RNBatchModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static void initialize(Application application) {
8686
boolean disableDoNotDisturb = resources.getBoolean(resources.getIdentifier("BATCH_DISABLE_DO_NOT_DISTURB", "bool", packageName));
8787
Batch.Messaging.setDoNotDisturbEnabled(!disableDoNotDisturb);
8888
} catch (Resources.NotFoundException e) {
89-
Batch.Messaging.setDoNotDisturbEnabled(true);
89+
Batch.Messaging.setDoNotDisturbEnabled(false);
9090
}
9191

9292
application.registerActivityLifecycleCallbacks(new BatchActivityLifecycleHelper());

ios/RNBatch.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ + (void)start
3939
if (disableDoNotDisturb != nil) {
4040
[BatchMessaging setDoNotDisturb:![disableDoNotDisturb boolValue]];
4141
} else {
42-
[BatchMessaging setDoNotDisturb:true];
42+
[BatchMessaging setDoNotDisturb:false];
4343
}
4444

4545
NSString *batchAPIKey = [info objectForKey:@"BatchAPIKey"];

0 commit comments

Comments
 (0)