Files
discord-decomp/lib/pushnotification/PushNotification.tsx
T
2026-11-01 12:12:55 +02:00

271 lines
8.2 KiB
TypeScript

// Metro module 10694 (f10695).
import { NativeModules, NativeEventEmitter } from "react-native";
import * as _PlatformUtils from "../../utils/PlatformUtils";
import PushNotificationIOS from "../../_bundle/PushNotificationIOS_10695";
import * as _Module10351 from "../../_bundle/Module10351";
import openNotificationSettings_native from "../../modules/native_permissions/mobile/openNotificationSettings.native";
import { HermesBuiltin } from "../../_hermes/prelude";
function $mk85340($env) {
return () => {
const r1 = {};
const r3 = $env[0];
HermesBuiltin.copyDataProperties(r1, r3);
r1.message = r3.message != null ? JSON.parse(r3.message) : null;
return r1;
};
}
function $mk85341() {
return () => {
throw new Error("TODO: Implement on Android");
};
}
function $mk85342() {
return () => {
throw new Error("TODO: Implement on Android");
};
}
function $mk85343() {
return () => {
throw new Error("TODO: Implement on Android");
};
}
function $mk85344() {
return () => {
throw new Error("TODO: Implement on Android");
};
}
function $mk85345() {
return () => {
throw new Error("TODO: Implement on Android");
};
}
function $mk85346() {
return () => {
throw new Error("TODO: Implement on Android");
};
}
function $mk85347() {
return (a0) => {
throw new Error(`Not implemented on Android: ${a0}`);
};
}
const PushNotificationAndroid = NativeModules.PushNotificationAndroid;
let c7188_5 = PushNotificationAndroid != null ? new NativeEventEmitter(NativeModules.PushNotificationAndroid) : null;
const r26 = {
getInitialNotification: () => _PlatformUtils.isAndroid() ? new Promise((c26796_0) => {
PushNotificationAndroid.getInitialNotification().then((result) => {
let env30284;
const r4 = env30284 = {};
env30284[0] = result;
c26796_0(result != null ? {
getData: $mk85340(r4),
getMessage: $mk85341(),
getSound: $mk85342(),
getCategory: $mk85343(),
getAlert: $mk85344(),
getContentAvailable: $mk85345(),
getBadgeCount: $mk85346(),
finish: $mk85347()
} : null);
});
}) : PushNotificationIOS.getInitialNotification(),
setCurrentUser: (a0, a1) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.setCurrentUser(a0, a1);
}
},
setMultiAccountUsers: (a0) => {
const r7 = JSON.stringify(a0);
if (_PlatformUtils.isAndroid()) {
if (PushNotificationAndroid != null) {
const setMultiAccountUsernames = PushNotificationAndroid.setMultiAccountUsernames;
if (setMultiAccountUsernames != null) {
setMultiAccountUsernames.call(PushNotificationAndroid, r7);
}
}
} else {
const NSUserDefaultsBridge = NativeModules.NSUserDefaultsBridge;
if (NSUserDefaultsBridge != null) {
const setMultiAccountUsersJSONString = NSUserDefaultsBridge.setMultiAccountUsersJSONString;
if (setMultiAccountUsersJSONString != null) {
setMultiAccountUsersJSONString.call(NSUserDefaultsBridge, r7);
}
}
}
},
clearPushNotificationLogs: () => {
if (_PlatformUtils.isAndroid()) {
_Module10351.default.clearLogs();
}
},
setApplicationIconBadgeNumber: (a0) => {
if (!_PlatformUtils.isAndroid()) {
PushNotificationIOS.setApplicationIconBadgeNumber(a0);
}
},
clearAllNotifications: () => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.clearAllNotifications();
} else {
PushNotificationIOS.setApplicationIconBadgeNumber(0);
}
},
presentLocalNotification: (a0) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.presentLocalNotification(a0);
} else {
PushNotificationIOS.presentLocalNotification(a0);
}
},
getDeliveredNotifications: () => {
const isAndroid = _PlatformUtils.isAndroid();
const r4 = Promise;
return isAndroid ? r4.resolve([]) : new r4((a0) => {
PushNotificationIOS.getDeliveredNotifications(a0);
});
},
removeDeliveredNotifications: (a0) => {
if (!_PlatformUtils.isAndroid()) {
PushNotificationIOS.removeDeliveredNotifications(a0);
}
},
scheduleLocalNotification: (a0) => {
if (!_PlatformUtils.isAndroid()) {
PushNotificationIOS.scheduleLocalNotification(a0);
}
},
getScheduledLocalNotifications: (a0) => {
if (!_PlatformUtils.isAndroid()) {
PushNotificationIOS.getScheduledLocalNotifications(a0);
}
},
cancelLocalNotifications: (a0) => {
if (!_PlatformUtils.isAndroid()) {
PushNotificationIOS.cancelLocalNotifications(a0);
}
},
cancelAllLocalNotifications: () => {
if (!_PlatformUtils.isAndroid()) {
PushNotificationIOS.cancelAllLocalNotifications();
}
},
checkPermissions: (a0) => {
if (_PlatformUtils.isAndroid()) {
a0({});
} else {
PushNotificationIOS.checkPermissions(a0);
}
},
requestPermissions: (a0) => _PlatformUtils.isAndroid() ? new Promise((resolve) => resolve({})) : PushNotificationIOS.requestPermissions(a0),
openNotificationSettings: () => {
openNotificationSettings_native();
},
addNotificationEventListener: (a0, a1) => {
if (_PlatformUtils.isAndroid()) {
if (a0 === "notification") {
c7188_5.addListener("notification", (a0) => {
let env26797;
const r4 = env26797 = {};
env26797[0] = a0;
const r3 = a0 == null ? null : {
getData: $mk85340(r4),
getMessage: $mk85341(),
getSound: $mk85342(),
getCategory: $mk85343(),
getAlert: $mk85344(),
getContentAvailable: $mk85345(),
getBadgeCount: $mk85346(),
finish: $mk85347()
};
if (r3 != null) {
a1(r3);
}
});
}
if (a0 === "localNotification") {
c7188_5.addListener("localNotification", (a0) => {
let env26798;
const r4 = env26798 = {};
env26798[0] = a0;
const r3 = a0 == null ? null : {
getData: $mk85340(r4),
getMessage: $mk85341(),
getSound: $mk85342(),
getCategory: $mk85343(),
getAlert: $mk85344(),
getContentAvailable: $mk85345(),
getBadgeCount: $mk85346(),
finish: $mk85347()
};
if (r3 != null) {
a1(r3);
}
});
}
PushNotificationAndroid.registerEventListener(a0);
} else {
PushNotificationIOS.addEventListener(a0, a1);
}
},
addRegisterEventListener: (a0) => {
let c18203_0 = a0;
if (_PlatformUtils.isAndroid()) {
c7188_5.addListener("register", (a0) => {
c18203_0(a0.token);
});
PushNotificationAndroid.registerEventListener("register");
} else {
PushNotificationIOS.addEventListener("register", a0);
}
},
getSoundsEnabled: () => new Promise((resolve) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.getSoundsEnabled().then((result) => resolve(result));
} else {
resolve(false);
}
}),
getVibrationsEnabled: () => new Promise((resolve) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.getVibrationsEnabled().then((result) => resolve(result));
} else {
resolve(false);
}
}),
getLightsEnabled: () => new Promise((resolve) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.getLightsEnabled().then((result) => resolve(result));
} else {
resolve(false);
}
}),
setSoundsEnabled: (a0) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.setSoundsEnabled(a0);
}
},
setVibrationsEnabled: (a0) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.setVibrationsEnabled(a0);
}
},
setLightsEnabled: (a0) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.setLightsEnabled(a0);
}
},
setAndroidNotifyEveryTime: (a0) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.setNotifyEveryTime(a0);
}
},
shouldAndroidNotifyEveryTime: () => new Promise((resolve) => {
if (_PlatformUtils.isAndroid()) {
PushNotificationAndroid.shouldNotifyEveryTime().then((result) => resolve(result));
} else {
resolve(false);
}
})
};
export default r26;