react-native-notify-kit 10.2.0 → 10.3.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.
Files changed (61) hide show
  1. package/README.md +6 -6
  2. package/android/src/main/AndroidManifest.xml +0 -1
  3. package/android/src/main/java/app/notifee/core/ForegroundService.java +3 -1
  4. package/android/src/main/java/app/notifee/core/NotifeeAlarmManager.java +4 -2
  5. package/android/src/main/java/app/notifee/core/NotificationManager.java +43 -43
  6. package/android/src/main/java/app/notifee/core/ReceiverService.java +18 -13
  7. package/android/src/main/java/app/notifee/core/database/NotifeeCoreDatabase.java +1 -4
  8. package/android/src/main/java/app/notifee/core/model/ChannelModel.java +8 -13
  9. package/android/src/main/java/app/notifee/core/model/IntervalTriggerModel.java +2 -6
  10. package/android/src/main/java/app/notifee/core/model/NotificationAndroidActionModel.java +1 -2
  11. package/android/src/main/java/app/notifee/core/model/NotificationAndroidModel.java +30 -33
  12. package/android/src/main/java/app/notifee/core/model/NotificationAndroidPressActionModel.java +3 -9
  13. package/android/src/main/java/app/notifee/core/model/NotificationAndroidStyleModel.java +6 -4
  14. package/android/src/main/java/app/notifee/core/model/TimestampTriggerModel.java +7 -4
  15. package/android/src/main/java/app/notifee/core/utility/BundleValueReader.java +65 -0
  16. package/android/src/main/java/app/notifee/core/utility/IntentUtils.java +0 -28
  17. package/android/src/main/java/app/notifee/core/utility/ObjectUtils.java +1 -1
  18. package/android/src/main/java/app/notifee/core/utility/ParcelableCompatReader.java +64 -0
  19. package/android/src/main/java/app/notifee/core/utility/PowerManagerUtils.java +79 -41
  20. package/android/src/main/java/app/notifee/core/utility/ResourceUtils.java +3 -0
  21. package/android/src/main/kotlin/io/invertase/notifee/NotifeeApiModule.kt +1 -1
  22. package/android/src/main/kotlin/io/invertase/notifee/NotifeeInitProvider.kt +0 -26
  23. package/android/src/main/kotlin/io/invertase/notifee/NotifeeReactUtils.kt +1 -2
  24. package/android/src/test/java/app/notifee/core/NotifeeAlarmManagerCurrentBehaviorTest.java +446 -0
  25. package/android/src/test/java/app/notifee/core/NotificationManagerCreateTriggerNotificationCurrentBehaviorTest.java +203 -0
  26. package/android/src/test/java/app/notifee/core/NotificationManagerPressActionOptOutTest.java +180 -0
  27. package/android/src/test/java/app/notifee/core/NotificationReceiverHandlerInitialNotificationTest.java +157 -0
  28. package/android/src/test/java/app/notifee/core/ReceiverServiceInitialNotificationTest.java +169 -0
  29. package/android/src/test/java/app/notifee/core/model/ChannelModelTest.java +116 -0
  30. package/android/src/test/java/app/notifee/core/model/IntervalTriggerModelTest.java +71 -0
  31. package/android/src/test/java/app/notifee/core/model/NotificationAndroidModelTest.java +309 -0
  32. package/android/src/test/java/app/notifee/core/model/NotificationAndroidStyleModelTest.java +154 -0
  33. package/android/src/test/java/app/notifee/core/model/TimestampTriggerModelTest.java +296 -14
  34. package/android/src/test/java/app/notifee/core/utility/BundleValueReaderTest.java +131 -0
  35. package/android/src/test/java/app/notifee/core/utility/ObjectUtilsTest.java +142 -0
  36. package/android/src/test/java/app/notifee/core/utility/ParcelableCompatReaderTest.java +124 -0
  37. package/android/src/test/java/io/invertase/notifee/HeadlessTaskReactHostTest.java +136 -0
  38. package/android/src/test/java/io/invertase/notifee/NotifeeEventSubscriberRoutingTest.java +262 -0
  39. package/android/src/test/java/io/invertase/notifee/NotifeeReactUtilsDrawerTest.java +24 -0
  40. package/cli/dist/lib/patchPodfile.d.ts +3 -1
  41. package/cli/dist/lib/patchPodfile.js +125 -33
  42. package/cli/dist/lib/patchPodfile.js.map +1 -1
  43. package/dist/index.d.ts +2 -0
  44. package/dist/types/Module.d.ts +20 -6
  45. package/dist/types/Notification.d.ts +5 -2
  46. package/dist/types/Notification.js +5 -2
  47. package/dist/types/Notification.js.map +1 -1
  48. package/dist/types/NotificationAndroid.d.ts +4 -0
  49. package/dist/types/NotificationAndroid.js +4 -0
  50. package/dist/types/NotificationAndroid.js.map +1 -1
  51. package/dist/types/PowerManagerInfo.d.ts +9 -4
  52. package/dist/version.d.ts +1 -1
  53. package/dist/version.js +1 -1
  54. package/ios/NotifeeCore/NotifeeCore.m +101 -114
  55. package/package.json +1 -1
  56. package/src/index.ts +2 -0
  57. package/src/types/Module.ts +20 -6
  58. package/src/types/Notification.ts +5 -2
  59. package/src/types/NotificationAndroid.ts +4 -0
  60. package/src/types/PowerManagerInfo.ts +9 -4
  61. package/src/version.ts +1 -1
@@ -105,9 +105,7 @@ public class NotificationAndroidPressActionModel {
105
105
  baseFlags |= Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
106
106
  break;
107
107
  case 12:
108
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
109
- baseFlags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
110
- }
108
+ baseFlags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
111
109
  break;
112
110
  case 13:
113
111
  baseFlags |= Intent.FLAG_ACTIVITY_NO_USER_ACTION;
@@ -125,14 +123,10 @@ public class NotificationAndroidPressActionModel {
125
123
  baseFlags |= Intent.FLAG_ACTIVITY_TASK_ON_HOME;
126
124
  break;
127
125
  case 18:
128
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
129
- baseFlags |= Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS;
130
- }
126
+ baseFlags |= Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS;
131
127
  break;
132
128
  case 19:
133
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
134
- baseFlags |= Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT;
135
- }
129
+ baseFlags |= Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT;
136
130
  break;
137
131
  case 20:
138
132
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
@@ -25,7 +25,8 @@ import androidx.core.app.NotificationCompat;
25
25
  import androidx.core.app.Person;
26
26
  import androidx.core.graphics.drawable.IconCompat;
27
27
  import app.notifee.core.Logger;
28
- import app.notifee.core.utility.ObjectUtils;
28
+ import app.notifee.core.utility.BundleValueReader;
29
+ import app.notifee.core.utility.ParcelableCompatReader;
29
30
  import app.notifee.core.utility.ResourceUtils;
30
31
  import app.notifee.core.utility.TextUtils;
31
32
  import com.google.common.util.concurrent.Futures;
@@ -114,7 +115,7 @@ public class NotificationAndroidStyleModel {
114
115
  @Nullable
115
116
  public ListenableFuture<NotificationCompat.Style> getStyleTask(
116
117
  ListeningExecutorService lExecutor) {
117
- int type = ObjectUtils.getInt(mNotificationAndroidStyleBundle.get("type"));
118
+ int type = BundleValueReader.getIntPreserving(mNotificationAndroidStyleBundle, "type");
118
119
  ListenableFuture<NotificationCompat.Style> styleTask = null;
119
120
 
120
121
  switch (type) {
@@ -312,12 +313,13 @@ public class NotificationAndroidStyleModel {
312
313
  }
313
314
 
314
315
  ArrayList<Bundle> messages =
315
- mNotificationAndroidStyleBundle.getParcelableArrayList("messages");
316
+ ParcelableCompatReader.getParcelableArrayList(
317
+ mNotificationAndroidStyleBundle, "messages", Bundle.class);
316
318
 
317
319
  for (int i = 0; i < Objects.requireNonNull(messages).size(); i++) {
318
320
  Bundle message = messages.get(i);
319
321
  Person messagePerson = null;
320
- long timestamp = ObjectUtils.getLong(message.get("timestamp"));
322
+ long timestamp = BundleValueReader.getLongPreserving(message, "timestamp");
321
323
 
322
324
  if (message.containsKey("person")) {
323
325
  messagePerson =
@@ -19,6 +19,7 @@ package app.notifee.core.model;
19
19
 
20
20
  import android.os.Bundle;
21
21
  import androidx.annotation.NonNull;
22
+ import app.notifee.core.utility.BundleValueReader;
22
23
  import app.notifee.core.utility.ObjectUtils;
23
24
  import java.util.Calendar;
24
25
  import java.util.concurrent.TimeUnit;
@@ -46,9 +47,11 @@ public class TimestampTriggerModel {
46
47
  // set initial values
47
48
  TimeUnit timeUnit = null;
48
49
  if (mTimeTriggerBundle.containsKey("repeatFrequency")) {
49
- int repeatFrequency = ObjectUtils.getInt(mTimeTriggerBundle.get("repeatFrequency"));
50
- mRepeatInterval = getRepeatInterval(mTimeTriggerBundle.get("repeatInterval"));
51
- mTimestamp = ObjectUtils.getLong(mTimeTriggerBundle.get("timestamp"));
50
+ int repeatFrequency =
51
+ BundleValueReader.getIntPreserving(mTimeTriggerBundle, "repeatFrequency");
52
+ mRepeatInterval =
53
+ getRepeatInterval(BundleValueReader.getValue(mTimeTriggerBundle, "repeatInterval"));
54
+ mTimestamp = BundleValueReader.getLongPreserving(mTimeTriggerBundle, "timestamp");
52
55
 
53
56
  switch (repeatFrequency) {
54
57
  case -1:
@@ -81,7 +84,7 @@ public class TimestampTriggerModel {
81
84
 
82
85
  Bundle alarmManagerBundle = mTimeTriggerBundle.getBundle("alarmManager");
83
86
 
84
- Object typeObj = alarmManagerBundle.get("type");
87
+ Object typeObj = BundleValueReader.getValue(alarmManagerBundle, "type");
85
88
 
86
89
  int type;
87
90
  if (typeObj != null) {
@@ -0,0 +1,65 @@
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
+
20
+ import android.os.Bundle;
21
+ import androidx.annotation.NonNull;
22
+ import androidx.annotation.Nullable;
23
+ import java.util.ArrayList;
24
+
25
+ public final class BundleValueReader {
26
+
27
+ private BundleValueReader() {}
28
+
29
+ @SuppressWarnings("deprecation")
30
+ @Nullable
31
+ public static Object getValue(@NonNull Bundle bundle, @Nullable String key) {
32
+ return bundle.get(key);
33
+ }
34
+
35
+ @Nullable
36
+ public static ArrayList<?> getArrayListValue(@NonNull Bundle bundle, @Nullable String key) {
37
+ return (ArrayList<?>) getValue(bundle, key);
38
+ }
39
+
40
+ public static int getIntPreserving(@NonNull Bundle bundle, @Nullable String key) {
41
+ return ObjectUtils.getInt(getValue(bundle, key));
42
+ }
43
+
44
+ public static int getIntPreserving(
45
+ @NonNull Bundle bundle, @Nullable String key, int defaultValue) {
46
+ if (!bundle.containsKey(key)) {
47
+ return defaultValue;
48
+ }
49
+
50
+ return getIntPreserving(bundle, key);
51
+ }
52
+
53
+ public static long getLongPreserving(@NonNull Bundle bundle, @Nullable String key) {
54
+ return ObjectUtils.getLong(getValue(bundle, key));
55
+ }
56
+
57
+ public static long getLongPreserving(
58
+ @NonNull Bundle bundle, @Nullable String key, long defaultValue) {
59
+ if (!bundle.containsKey(key)) {
60
+ return defaultValue;
61
+ }
62
+
63
+ return getLongPreserving(bundle, key);
64
+ }
65
+ }
@@ -22,40 +22,12 @@ import static app.notifee.core.ContextHolder.getApplicationContext;
22
22
  import android.app.Activity;
23
23
  import android.content.Context;
24
24
  import android.content.Intent;
25
- import android.content.pm.PackageManager;
26
- import android.content.pm.ResolveInfo;
27
- import android.os.Build;
28
25
  import androidx.annotation.Nullable;
29
26
  import app.notifee.core.Logger;
30
- import java.util.List;
31
27
 
32
28
  public class IntentUtils {
33
29
  private static final String TAG = "IntentUtils";
34
30
 
35
- @SuppressWarnings("deprecation")
36
- public static boolean isAvailableOnDevice(Context ctx, Intent intent) {
37
- try {
38
- if (ctx == null || intent == null) {
39
- return false;
40
- }
41
-
42
- final PackageManager mgr = ctx.getPackageManager();
43
- List<ResolveInfo> list;
44
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
45
- list =
46
- mgr.queryIntentActivities(
47
- intent, PackageManager.ResolveInfoFlags.of(PackageManager.MATCH_DEFAULT_ONLY));
48
- } else {
49
- list = mgr.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
50
- }
51
- return !list.isEmpty();
52
- } catch (Exception e) {
53
- Logger.e(TAG, "An error occurred whilst trying to check if intent is available on device", e);
54
-
55
- return false;
56
- }
57
- }
58
-
59
31
  public static String getActivityName(Intent intent) {
60
32
  if (intent == null) {
61
33
  return null;
@@ -111,7 +111,7 @@ public class ObjectUtils {
111
111
  public static Map<String, Object> bundleToMap(Bundle bundle) throws IllegalArgumentException {
112
112
  Map<String, Object> map = new HashMap<>();
113
113
  for (String key : bundle.keySet()) {
114
- Object value = bundle.get(key);
114
+ Object value = BundleValueReader.getValue(bundle, key);
115
115
  if (value == null) {
116
116
  map.put(key, null);
117
117
  } else if (value.getClass().isArray()) {
@@ -0,0 +1,64 @@
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
+
20
+ import android.os.Build;
21
+ import android.os.Bundle;
22
+ import android.os.Parcelable;
23
+ import androidx.annotation.NonNull;
24
+ import androidx.annotation.Nullable;
25
+ import java.util.ArrayList;
26
+
27
+ public final class ParcelableCompatReader {
28
+
29
+ private ParcelableCompatReader() {}
30
+
31
+ @Nullable
32
+ public static <T extends Parcelable> T getParcelable(
33
+ @NonNull Bundle bundle, @Nullable String key, @NonNull Class<T> clazz) {
34
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
35
+ return bundle.getParcelable(key, clazz);
36
+ }
37
+
38
+ return getParcelableLegacy(bundle, key);
39
+ }
40
+
41
+ @Nullable
42
+ public static <T extends Parcelable> ArrayList<T> getParcelableArrayList(
43
+ @NonNull Bundle bundle, @Nullable String key, @NonNull Class<T> clazz) {
44
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
45
+ return bundle.getParcelableArrayList(key, clazz);
46
+ }
47
+
48
+ return getParcelableArrayListLegacy(bundle, key);
49
+ }
50
+
51
+ @SuppressWarnings({"deprecation", "unchecked"})
52
+ @Nullable
53
+ private static <T extends Parcelable> T getParcelableLegacy(
54
+ @NonNull Bundle bundle, @Nullable String key) {
55
+ return bundle.getParcelable(key);
56
+ }
57
+
58
+ @SuppressWarnings({"deprecation", "unchecked"})
59
+ @Nullable
60
+ private static <T extends Parcelable> ArrayList<T> getParcelableArrayListLegacy(
61
+ @NonNull Bundle bundle, @Nullable String key) {
62
+ return bundle.getParcelableArrayList(key);
63
+ }
64
+ }
@@ -18,6 +18,7 @@ package app.notifee.core.utility;
18
18
  */
19
19
 
20
20
  import android.app.Activity;
21
+ import android.content.ActivityNotFoundException;
21
22
  import android.content.ComponentName;
22
23
  import android.content.Context;
23
24
  import android.content.Intent;
@@ -55,24 +56,12 @@ public class PowerManagerUtils {
55
56
  * @param activity
56
57
  */
57
58
  public static void openBatteryOptimizationSettings(Activity activity) {
58
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
59
- return;
60
- }
61
-
62
59
  try {
63
60
  Intent intent = new Intent();
64
61
  intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
65
62
  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
66
63
 
67
64
  if (activity != null) {
68
- Boolean isAvailableOnDevice =
69
- IntentUtils.isAvailableOnDevice(ContextHolder.getApplicationContext(), intent);
70
-
71
- if (!isAvailableOnDevice) {
72
- Logger.d(TAG, "battery optimization settings is not available on device");
73
- return;
74
- }
75
-
76
65
  IntentUtils.startActivityOnUiThread(activity, intent);
77
66
  }
78
67
  } catch (Exception e) {
@@ -86,9 +75,6 @@ public class PowerManagerUtils {
86
75
  * @param context
87
76
  */
88
77
  public static Boolean isBatteryOptimizationEnabled(Context context) {
89
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
90
- return false;
91
- }
92
78
  PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
93
79
  return !pm.isIgnoringBatteryOptimizations(context.getPackageName());
94
80
  }
@@ -129,7 +115,7 @@ public class PowerManagerUtils {
129
115
  public static PowerManagerInfo getPowerManagerInfo() {
130
116
  String activityName;
131
117
 
132
- Intent intent = findPowerManagerIntent(ContextHolder.getApplicationContext());
118
+ Intent intent = getFirstPowerManagerIntent();
133
119
  activityName = IntentUtils.getActivityName(intent);
134
120
 
135
121
  PowerManagerInfo result =
@@ -143,37 +129,90 @@ public class PowerManagerUtils {
143
129
  * @param activity
144
130
  */
145
131
  public static void openPowerManagerSettings(Activity activity) {
146
- Intent intent = getPowerManagerIntent();
147
- if (intent == null) {
148
- intent = findPowerManagerIntent(ContextHolder.getApplicationContext());
132
+ if (activity == null) {
133
+ Logger.w(TAG, "Activity is null when trying to open the device's power manager");
134
+ return;
149
135
  }
150
136
 
151
- if (intent != null) {
152
- try {
153
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
154
- IntentUtils.startActivityOnUiThread(activity, intent);
155
- } catch (Exception exception) {
156
- Logger.e(
157
- TAG, "Unable to start activity: " + IntentUtils.getActivityName(intent), exception);
158
- }
159
- } else {
137
+ Context context = ContextHolder.getApplicationContext();
138
+ if (context == null) {
139
+ Logger.w(TAG, "Unable to get application context when opening the device's power manager");
140
+ return;
141
+ }
142
+
143
+ List<Intent> possibleIntents = getPowerManagerIntentCandidates();
144
+ if (possibleIntents.isEmpty()) {
160
145
  Logger.w(TAG, "Unable to find an activity to open the device's power manager");
146
+ return;
147
+ }
148
+
149
+ activity.runOnUiThread(
150
+ () -> {
151
+ for (Intent possibleIntent : possibleIntents) {
152
+ if (startPowerManagerIntent(context, possibleIntent)) {
153
+ return;
154
+ }
155
+ }
156
+
157
+ Logger.w(TAG, "Unable to open the device's power manager");
158
+ });
159
+ }
160
+
161
+ private static Intent getFirstPowerManagerIntent() {
162
+ List<Intent> possibleIntents = getManufacturerPowerManagerIntents(getManufacturerName());
163
+ if (possibleIntents.isEmpty()) {
164
+ return null;
165
+ }
166
+
167
+ return possibleIntents.get(0);
168
+ }
169
+
170
+ private static List<Intent> getPowerManagerIntentCandidates() {
171
+ List<Intent> possibleIntents = new ArrayList<>();
172
+ Intent cachedIntent = getPowerManagerIntent();
173
+
174
+ if (cachedIntent != null) {
175
+ possibleIntents.add(cachedIntent);
161
176
  }
177
+
178
+ for (Intent manufacturerIntent : getManufacturerPowerManagerIntents(getManufacturerName())) {
179
+ if (!containsEquivalentIntent(possibleIntents, manufacturerIntent)) {
180
+ possibleIntents.add(manufacturerIntent);
181
+ }
182
+ }
183
+
184
+ return possibleIntents;
162
185
  }
163
186
 
164
- private static Intent findPowerManagerIntent(Context context) {
165
- String manufacturerName = Build.BRAND.toLowerCase(Locale.US);
166
- List<Intent> possibleIntents = getManufacturerPowerManagerIntents(manufacturerName);
187
+ private static String getManufacturerName() {
188
+ return Build.BRAND.toLowerCase(Locale.US);
189
+ }
167
190
 
168
- for (int i = 0; i < possibleIntents.size(); i++) {
169
- Intent possibleIntent = possibleIntents.get(i);
170
- Boolean isAvailableOnDevice = IntentUtils.isAvailableOnDevice(context, possibleIntent);
171
- if (isAvailableOnDevice) {
172
- setPowerManagerIntentCache(possibleIntent);
173
- return possibleIntent;
191
+ private static boolean containsEquivalentIntent(List<Intent> possibleIntents, Intent candidate) {
192
+ for (Intent possibleIntent : possibleIntents) {
193
+ if (possibleIntent.filterEquals(candidate)) {
194
+ return true;
174
195
  }
175
196
  }
176
- return null;
197
+
198
+ return false;
199
+ }
200
+
201
+ private static boolean startPowerManagerIntent(Context context, Intent possibleIntent) {
202
+ Intent intent = new Intent(possibleIntent);
203
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
204
+
205
+ try {
206
+ context.startActivity(intent);
207
+ setPowerManagerIntentCache(intent);
208
+ return true;
209
+ } catch (ActivityNotFoundException | SecurityException e) {
210
+ Logger.w(TAG, "Unable to start activity: " + IntentUtils.getActivityName(intent), e);
211
+ } catch (RuntimeException e) {
212
+ Logger.w(TAG, "Unable to start activity: " + IntentUtils.getActivityName(intent), e);
213
+ }
214
+
215
+ return false;
177
216
  }
178
217
 
179
218
  private static List<Intent> getManufacturerPowerManagerIntents(String manufacturerName) {
@@ -249,9 +288,8 @@ public class PowerManagerUtils {
249
288
  createIntent(
250
289
  "com.oppo.safe", "com.oppo.safe.permission.startup.StartupAppListActivity"),
251
290
  createIntent(
252
- "com.coloros.safecenter",
253
- "com.coloros.safecenter.startupapp.StartupAppListActivity")
254
- .setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS),
291
+ "com.coloros.safecenter",
292
+ "com.coloros.safecenter.startupapp.StartupAppListActivity"),
255
293
  createIntent(
256
294
  "com.coloros.oppoguardelf",
257
295
  "com.coloros.powermanager.fuelgaue.PowerUsageModelActivity"),
@@ -17,6 +17,7 @@ package app.notifee.core.utility;
17
17
  *
18
18
  */
19
19
 
20
+ import android.annotation.SuppressLint;
20
21
  import android.content.Context;
21
22
  import android.content.pm.ApplicationInfo;
22
23
  import android.graphics.Bitmap;
@@ -253,6 +254,7 @@ public class ResourceUtils {
253
254
  }
254
255
 
255
256
  /** Attempts to find a resource id by name and type */
257
+ @SuppressLint("DiscouragedApi")
256
258
  private static int getResourceIdByName(String name, String type) {
257
259
  if (name == null || name.isEmpty()) {
258
260
  return 0;
@@ -271,6 +273,7 @@ public class ResourceUtils {
271
273
  Context context = ContextHolder.getApplicationContext();
272
274
  String packageName = context.getPackageName();
273
275
 
276
+ // Consumer resource names are provided dynamically from JS, so runtime lookup is intentional.
274
277
  int id = context.getResources().getIdentifier(name, type, packageName);
275
278
  getResourceIdCache().put(key, id);
276
279
  return id;
@@ -199,7 +199,7 @@ class NotifeeApiModule(reactContext: ReactApplicationContext) :
199
199
 
200
200
  override fun getChannelGroup(channelGroupId: String, promise: Promise) {
201
201
  Notifee.getInstance()
202
- .getChannel(channelGroupId) { e, bundle ->
202
+ .getChannelGroup(channelGroupId) { e, bundle ->
203
203
  NotifeeReactUtils.promiseResolver(promise, e, bundle)
204
204
  }
205
205
  }
@@ -6,7 +6,6 @@ package io.invertase.notifee
6
6
 
7
7
  import app.notifee.core.InitProvider
8
8
  import app.notifee.core.Notifee
9
- import com.facebook.react.modules.systeminfo.ReactNativeVersion
10
9
 
11
10
  class NotifeeInitProvider : InitProvider() {
12
11
 
@@ -15,29 +14,4 @@ class NotifeeInitProvider : InitProvider() {
15
14
  Notifee.initialize(NotifeeEventSubscriber())
16
15
  return result
17
16
  }
18
-
19
- private fun getApplicationVersionString(): String {
20
- val context = this.context ?: return "unknown"
21
- return try {
22
- val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
23
- pInfo.versionName ?: "unknown"
24
- } catch (e: Exception) {
25
- "unknown"
26
- }
27
- }
28
-
29
- private fun getReactNativeVersionString(): String {
30
- val versionMap = ReactNativeVersion.VERSION
31
- val major = versionMap["major"] as Int
32
- val minor = versionMap["minor"] as Int
33
- val patch = versionMap["patch"] as Int
34
- val prerelease = versionMap["prerelease"] as? String
35
-
36
- return buildString {
37
- append("$major.$minor.$patch")
38
- if (prerelease != null) {
39
- append(".$prerelease")
40
- }
41
- }
42
- }
43
17
  }
@@ -5,7 +5,6 @@
5
5
  package io.invertase.notifee
6
6
 
7
7
  import android.annotation.SuppressLint
8
- import android.os.Build
9
8
  import android.os.Bundle
10
9
  import android.util.Log
11
10
  import androidx.lifecycle.Lifecycle
@@ -138,7 +137,7 @@ object NotifeeReactUtils {
138
137
  try {
139
138
  val service = context.getSystemService("statusbar")
140
139
  val statusbarManager = Class.forName("android.app.StatusBarManager")
141
- val methodName = if (Build.VERSION.SDK_INT >= 17) "collapsePanels" else "collapse"
140
+ val methodName = "collapsePanels"
142
141
  val collapse: Method = statusbarManager.getMethod(methodName)
143
142
  collapse.isAccessible = true
144
143
  collapse.invoke(service)