expo-notifications 0.15.0 → 0.15.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/CHANGELOG.md +6 -0
- package/android/build.gradle +2 -2
- package/ios/EXNotifications.xcframework/ios-arm64/EXNotifications.framework/EXNotifications +0 -0
- package/ios/EXNotifications.xcframework/ios-arm64/EXNotifications.framework/Info.plist +0 -0
- package/ios/EXNotifications.xcframework/ios-arm64_x86_64-simulator/EXNotifications.framework/EXNotifications +0 -0
- package/ios/EXNotifications.xcframework/ios-arm64_x86_64-simulator/EXNotifications.framework/Info.plist +0 -0
- package/package.json +2 -2
- package/android/src/main/java/expo/modules/notifications/badge/SetBadgeCountNotificationEffect.java +0 -56
- package/android/src/main/java/expo/modules/notifications/notifications/presentation/builders/BadgeSettingNotificationBuilder.java +0 -66
package/CHANGELOG.md
CHANGED
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '0.15.
|
|
6
|
+
version = '0.15.1'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -74,7 +74,7 @@ android {
|
|
|
74
74
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
75
75
|
targetSdkVersion safeExtGet("targetSdkVersion", 31)
|
|
76
76
|
versionCode 21
|
|
77
|
-
versionName '0.15.
|
|
77
|
+
versionName '0.15.1'
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
lintOptions {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-notifications",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"description": "Notifications module",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"expo": "*"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "be6e0e7ea3f7fd1ab8368137260a7ad1b1bf12a8"
|
|
62
62
|
}
|
package/android/src/main/java/expo/modules/notifications/badge/SetBadgeCountNotificationEffect.java
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
package expo.modules.notifications.badge;
|
|
2
|
-
|
|
3
|
-
import android.app.Notification;
|
|
4
|
-
import android.content.Context;
|
|
5
|
-
import android.util.Log;
|
|
6
|
-
|
|
7
|
-
import expo.modules.core.ModuleRegistry;
|
|
8
|
-
import expo.modules.core.errors.CodedRuntimeException;
|
|
9
|
-
|
|
10
|
-
import androidx.annotation.Nullable;
|
|
11
|
-
import expo.modules.notifications.badge.interfaces.BadgeManager;
|
|
12
|
-
import expo.modules.notifications.notifications.presentation.builders.BadgeSettingNotificationBuilder;
|
|
13
|
-
import expo.modules.notifications.notifications.presentation.effects.BaseNotificationEffect;
|
|
14
|
-
|
|
15
|
-
public class SetBadgeCountNotificationEffect extends BaseNotificationEffect {
|
|
16
|
-
private static final String EXTRAS_BADGE_KEY = BadgeSettingNotificationBuilder.EXTRAS_BADGE_KEY;
|
|
17
|
-
|
|
18
|
-
private BadgeManager mBadgeManager;
|
|
19
|
-
|
|
20
|
-
public SetBadgeCountNotificationEffect(Context context) {
|
|
21
|
-
super(context);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@Override
|
|
25
|
-
public void onCreate(ModuleRegistry moduleRegistry) {
|
|
26
|
-
super.onCreate(moduleRegistry);
|
|
27
|
-
mBadgeManager = moduleRegistry.getSingletonModule("BadgeManager", BadgeManager.class);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@Override
|
|
31
|
-
public boolean onNotificationPresented(@Nullable String tag, int id, Notification notification) {
|
|
32
|
-
return applyBadgeFromNotification(notification);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@Override
|
|
36
|
-
public boolean onNotificationPresentationFailed(@Nullable String tag, int id, Notification notification) {
|
|
37
|
-
// We could also just return false here. Then, notifications that failed to be presented
|
|
38
|
-
// wouldn't affect badge count. Applying badge count from failed notifications lets us
|
|
39
|
-
// properly handle badge-update-only notifications.
|
|
40
|
-
return applyBadgeFromNotification(notification);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
private boolean applyBadgeFromNotification(Notification notification) {
|
|
44
|
-
try {
|
|
45
|
-
if (notification.extras.get(EXTRAS_BADGE_KEY) != null && mBadgeManager != null) {
|
|
46
|
-
mBadgeManager.setBadgeCount(notification.extras.getInt(EXTRAS_BADGE_KEY));
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
} catch (CodedRuntimeException e) {
|
|
50
|
-
// We can't do anything but log the error and return false.
|
|
51
|
-
Log.e(e.getCode(), e.getMessage());
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
package expo.modules.notifications.notifications.presentation.builders;
|
|
2
|
-
|
|
3
|
-
import android.app.Notification;
|
|
4
|
-
import android.content.Context;
|
|
5
|
-
import android.os.Bundle;
|
|
6
|
-
|
|
7
|
-
import androidx.core.app.NotificationCompat;
|
|
8
|
-
import expo.modules.notifications.notifications.model.NotificationContent;
|
|
9
|
-
import me.leolin.shortcutbadger.ShortcutBadger;
|
|
10
|
-
|
|
11
|
-
public class BadgeSettingNotificationBuilder extends ExpoNotificationBuilder {
|
|
12
|
-
public static final String EXTRAS_BADGE_KEY = "badge";
|
|
13
|
-
|
|
14
|
-
public BadgeSettingNotificationBuilder(Context context) {
|
|
15
|
-
super(context);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@Override
|
|
19
|
-
protected NotificationCompat.Builder createBuilder() {
|
|
20
|
-
NotificationCompat.Builder builder = super.createBuilder();
|
|
21
|
-
|
|
22
|
-
if (shouldSetBadge()) {
|
|
23
|
-
// Forward information about badge count to set
|
|
24
|
-
// to SetBadgeCountNotificationEffect.
|
|
25
|
-
Bundle extras = builder.getExtras();
|
|
26
|
-
extras.putInt(EXTRAS_BADGE_KEY, getBadgeCount());
|
|
27
|
-
builder.setExtras(extras);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return builder;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
@Override
|
|
34
|
-
public Notification build() {
|
|
35
|
-
Notification notification = super.build();
|
|
36
|
-
|
|
37
|
-
if (shouldSetBadge()) {
|
|
38
|
-
// Xiaomi devices require this extra notification configuration step
|
|
39
|
-
// https://github.com/leolin310148/ShortcutBadger/wiki/Xiaomi-Device-Support
|
|
40
|
-
// Badge for other devices is set as an effect in SetBadgeCountNotificationEffect
|
|
41
|
-
ShortcutBadger.applyNotification(getContext(), notification, getBadgeCount());
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return notification;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
private boolean shouldSetBadge() {
|
|
48
|
-
boolean behaviorAllowsBadge = getNotificationBehavior() == null || getNotificationBehavior().shouldSetBadge();
|
|
49
|
-
|
|
50
|
-
NotificationContent content = getNotificationContent();
|
|
51
|
-
boolean contentDefinesBadge = content.getBadgeCount() != null;
|
|
52
|
-
|
|
53
|
-
return behaviorAllowsBadge && contentDefinesBadge;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
private int getBadgeCount() {
|
|
57
|
-
Number badgeCount = getNotificationContent().getBadgeCount();
|
|
58
|
-
if (badgeCount == null) {
|
|
59
|
-
// We should never end up here, since getBadgeCount is guarded by
|
|
60
|
-
// shouldSetBadge, which checks if badgeCount is null, but in case
|
|
61
|
-
// this is ever called, let's not crash the application.
|
|
62
|
-
return 0;
|
|
63
|
-
}
|
|
64
|
-
return badgeCount.intValue();
|
|
65
|
-
}
|
|
66
|
-
}
|