react-native-notify-kit 9.7.0 → 10.1.0
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/README.md +140 -6
- package/RNNotifeeCore.podspec +2 -0
- package/android/src/androidTest/java/app/notifee/core/RebootRecoveryTest.java +94 -2
- package/android/src/main/AndroidManifest.xml +8 -7
- package/android/src/main/java/app/notifee/core/NotificationManager.java +2 -0
- package/android/src/main/java/app/notifee/core/model/NotificationAndroidModel.java +8 -3
- package/android/src/main/java/app/notifee/core/utility/ResourceUtils.java +28 -0
- package/android/src/test/java/app/notifee/core/model/NotificationAndroidModelSmallIconFallbackTest.java +74 -0
- package/android/src/test/java/app/notifee/core/utility/ResourceUtilsFallbackIconTest.java +116 -0
- package/cli/bin/react-native-notify-kit +2 -0
- package/cli/dist/cli.bundle.js +20834 -0
- package/cli/dist/cli.d.ts +2 -0
- package/cli/dist/cli.js +87 -0
- package/cli/dist/cli.js.map +1 -0
- package/cli/dist/commands/initNse.d.ts +12 -0
- package/cli/dist/commands/initNse.js +212 -0
- package/cli/dist/commands/initNse.js.map +1 -0
- package/cli/dist/lib/detectProject.d.ts +15 -0
- package/cli/dist/lib/detectProject.js +156 -0
- package/cli/dist/lib/detectProject.js.map +1 -0
- package/cli/dist/lib/logger.d.ts +4 -0
- package/cli/dist/lib/logger.js +24 -0
- package/cli/dist/lib/logger.js.map +1 -0
- package/cli/dist/lib/patchPodfile.d.ts +12 -0
- package/cli/dist/lib/patchPodfile.js +143 -0
- package/cli/dist/lib/patchPodfile.js.map +1 -0
- package/cli/dist/lib/patchXcodeProject.d.ts +25 -0
- package/cli/dist/lib/patchXcodeProject.js +239 -0
- package/cli/dist/lib/patchXcodeProject.js.map +1 -0
- package/cli/dist/lib/writeTemplates.d.ts +11 -0
- package/cli/dist/lib/writeTemplates.js +82 -0
- package/cli/dist/lib/writeTemplates.js.map +1 -0
- package/cli/dist/templates/Info.plist.tmpl +29 -0
- package/cli/dist/templates/NotificationService.swift.tmpl +32 -0
- package/cli/dist/templates/NotifyKitNSE.entitlements.tmpl +6 -0
- package/cli/dist/templates/templates/Info.plist.tmpl +29 -0
- package/cli/dist/templates/templates/NotificationService.swift.tmpl +73 -0
- package/cli/dist/templates/templates/NotifyKitNSE.entitlements.tmpl +6 -0
- package/dist/NotifeeApiModule.d.ts +17 -0
- package/dist/NotifeeApiModule.js +66 -1
- package/dist/NotifeeApiModule.js.map +1 -1
- package/dist/fcm/index.d.ts +4 -0
- package/dist/fcm/index.js +3 -0
- package/dist/fcm/index.js.map +1 -0
- package/dist/fcm/parseFcmPayload.d.ts +16 -0
- package/dist/fcm/parseFcmPayload.js +37 -0
- package/dist/fcm/parseFcmPayload.js.map +1 -0
- package/dist/fcm/reconstructNotification.d.ts +8 -0
- package/dist/fcm/reconstructNotification.js +167 -0
- package/dist/fcm/reconstructNotification.js.map +1 -0
- package/dist/fcm/types.d.ts +51 -0
- package/dist/fcm/types.js +6 -0
- package/dist/fcm/types.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types/Module.d.ts +21 -0
- package/dist/validators/validateTrigger.js +16 -0
- package/dist/validators/validateTrigger.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +38 -3
- package/server/README.md +129 -0
- package/server/dist/android.d.ts +8 -0
- package/server/dist/android.d.ts.map +1 -0
- package/server/dist/android.js +20 -0
- package/server/dist/android.js.map +1 -0
- package/server/dist/buildPayload.d.ts +3 -0
- package/server/dist/buildPayload.d.ts.map +1 -0
- package/server/dist/buildPayload.js +82 -0
- package/server/dist/buildPayload.js.map +1 -0
- package/server/dist/index.d.ts +6 -0
- package/server/dist/index.d.ts.map +1 -0
- package/server/dist/index.js +12 -0
- package/server/dist/index.js.map +1 -0
- package/server/dist/ios.d.ts +11 -0
- package/server/dist/ios.d.ts.map +1 -0
- package/server/dist/ios.js +61 -0
- package/server/dist/ios.js.map +1 -0
- package/server/dist/serialize.d.ts +11 -0
- package/server/dist/serialize.d.ts.map +1 -0
- package/server/dist/serialize.js +32 -0
- package/server/dist/serialize.js.map +1 -0
- package/server/dist/types.d.ts +2 -0
- package/server/dist/types.d.ts.map +1 -0
- package/server/dist/types.js +3 -0
- package/server/dist/types.js.map +1 -0
- package/server/dist/validation.d.ts +3 -0
- package/server/dist/validation.d.ts.map +1 -0
- package/server/dist/validation.js +101 -0
- package/server/dist/validation.js.map +1 -0
- package/server/package.json +5 -0
- package/server/src/android.ts +27 -0
- package/server/src/buildPayload.ts +91 -0
- package/server/src/index.ts +12 -0
- package/server/src/ios.ts +88 -0
- package/server/src/serialize.ts +39 -0
- package/server/src/types.ts +24 -0
- package/server/src/validation.ts +134 -0
- package/server/tsconfig.json +25 -0
- package/src/NotifeeApiModule.ts +80 -1
- package/src/fcm/index.ts +4 -0
- package/src/fcm/parseFcmPayload.ts +56 -0
- package/src/fcm/reconstructNotification.ts +201 -0
- package/src/fcm/types.ts +57 -0
- package/src/index.ts +2 -0
- package/src/internal/fcmContract.d.ts +150 -0
- package/src/types/Module.ts +23 -0
- package/src/validators/validateTrigger.ts +24 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
package app.notifee.core.utility;
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this library except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import static org.junit.Assert.assertEquals;
|
|
20
|
+
import static org.junit.Assert.assertNotEquals;
|
|
21
|
+
import static org.mockito.Mockito.mock;
|
|
22
|
+
import static org.mockito.Mockito.when;
|
|
23
|
+
|
|
24
|
+
import android.content.Context;
|
|
25
|
+
import android.content.pm.ApplicationInfo;
|
|
26
|
+
import org.junit.Test;
|
|
27
|
+
import org.junit.runner.RunWith;
|
|
28
|
+
import org.robolectric.RobolectricTestRunner;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Unit coverage for {@link ResourceUtils#getFallbackSmallIconId(Context)} — the three-layer
|
|
32
|
+
* fallback that keeps a notification valid when the user-supplied {@code smallIcon} string cannot
|
|
33
|
+
* be resolved. Guards the invariant that the method never returns 0 and never throws, which is what
|
|
34
|
+
* {@link app.notifee.core.NotificationManager} relies on to avoid the {@code
|
|
35
|
+
* IllegalArgumentException: Invalid notification (no valid small icon)} crash that motivated the
|
|
36
|
+
* fix (upstream invertase/notifee#733).
|
|
37
|
+
*/
|
|
38
|
+
@RunWith(RobolectricTestRunner.class)
|
|
39
|
+
public class ResourceUtilsFallbackIconTest {
|
|
40
|
+
|
|
41
|
+
@Test
|
|
42
|
+
public void returnsApplicationInfoIcon_whenIconNonZero() {
|
|
43
|
+
ApplicationInfo info = new ApplicationInfo();
|
|
44
|
+
info.icon = 0x7f080001;
|
|
45
|
+
info.logo = 0x7f080002;
|
|
46
|
+
Context context = mock(Context.class);
|
|
47
|
+
when(context.getApplicationInfo()).thenReturn(info);
|
|
48
|
+
|
|
49
|
+
assertEquals(0x7f080001, ResourceUtils.getFallbackSmallIconId(context));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@Test
|
|
53
|
+
public void returnsApplicationInfoLogo_whenIconZeroAndLogoNonZero() {
|
|
54
|
+
ApplicationInfo info = new ApplicationInfo();
|
|
55
|
+
info.icon = 0;
|
|
56
|
+
info.logo = 0x7f080002;
|
|
57
|
+
Context context = mock(Context.class);
|
|
58
|
+
when(context.getApplicationInfo()).thenReturn(info);
|
|
59
|
+
|
|
60
|
+
assertEquals(0x7f080002, ResourceUtils.getFallbackSmallIconId(context));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@Test
|
|
64
|
+
public void returnsSystemDefault_whenIconAndLogoZero() {
|
|
65
|
+
ApplicationInfo info = new ApplicationInfo();
|
|
66
|
+
info.icon = 0;
|
|
67
|
+
info.logo = 0;
|
|
68
|
+
Context context = mock(Context.class);
|
|
69
|
+
when(context.getApplicationInfo()).thenReturn(info);
|
|
70
|
+
|
|
71
|
+
assertEquals(android.R.drawable.ic_dialog_info, ResourceUtils.getFallbackSmallIconId(context));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@Test
|
|
75
|
+
public void returnsSystemDefault_whenGetApplicationInfoThrows() {
|
|
76
|
+
Context context = mock(Context.class);
|
|
77
|
+
when(context.getApplicationInfo()).thenThrow(new RuntimeException("boom"));
|
|
78
|
+
|
|
79
|
+
assertEquals(android.R.drawable.ic_dialog_info, ResourceUtils.getFallbackSmallIconId(context));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@Test
|
|
83
|
+
public void returnsSystemDefault_whenContextIsNull() {
|
|
84
|
+
assertEquals(android.R.drawable.ic_dialog_info, ResourceUtils.getFallbackSmallIconId(null));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@Test
|
|
88
|
+
public void neverReturnsZero_acrossAllPaths() {
|
|
89
|
+
// Path 1: icon present
|
|
90
|
+
ApplicationInfo infoIcon = new ApplicationInfo();
|
|
91
|
+
infoIcon.icon = 0x7f080001;
|
|
92
|
+
Context ctxIcon = mock(Context.class);
|
|
93
|
+
when(ctxIcon.getApplicationInfo()).thenReturn(infoIcon);
|
|
94
|
+
assertNotEquals(0, ResourceUtils.getFallbackSmallIconId(ctxIcon));
|
|
95
|
+
|
|
96
|
+
// Path 2: logo fallback
|
|
97
|
+
ApplicationInfo infoLogo = new ApplicationInfo();
|
|
98
|
+
infoLogo.logo = 0x7f080002;
|
|
99
|
+
Context ctxLogo = mock(Context.class);
|
|
100
|
+
when(ctxLogo.getApplicationInfo()).thenReturn(infoLogo);
|
|
101
|
+
assertNotEquals(0, ResourceUtils.getFallbackSmallIconId(ctxLogo));
|
|
102
|
+
|
|
103
|
+
// Path 3: system default (empty ApplicationInfo, icon and logo both zero)
|
|
104
|
+
Context ctxEmpty = mock(Context.class);
|
|
105
|
+
when(ctxEmpty.getApplicationInfo()).thenReturn(new ApplicationInfo());
|
|
106
|
+
assertNotEquals(0, ResourceUtils.getFallbackSmallIconId(ctxEmpty));
|
|
107
|
+
|
|
108
|
+
// Path 4: exception branch
|
|
109
|
+
Context ctxThrows = mock(Context.class);
|
|
110
|
+
when(ctxThrows.getApplicationInfo()).thenThrow(new RuntimeException());
|
|
111
|
+
assertNotEquals(0, ResourceUtils.getFallbackSmallIconId(ctxThrows));
|
|
112
|
+
|
|
113
|
+
// Path 5: null context
|
|
114
|
+
assertNotEquals(0, ResourceUtils.getFallbackSmallIconId(null));
|
|
115
|
+
}
|
|
116
|
+
}
|