164 lines
5.8 KiB
TypeScript
164 lines
5.8 KiB
TypeScript
// Metro module 11506 (f11507).
|
|
import _slicedToArray from "../../../_bundle/_slicedToArray";
|
|
import { useState, useEffect } from "react";
|
|
import { NativeModules } from "react-native";
|
|
import PushNotificationPermissionStore from "../../../stores/native/PushNotificationPermissionStore";
|
|
import { EventActionType } from "./components/notification/NotificationPermissionConstants";
|
|
import { AnalyticEvents } from "../../../Constants";
|
|
import { NotificationAuthorizationStatus } from "../../native_permissions/NativePermissionConstants";
|
|
import openNotificationSettings_native from "../../native_permissions/mobile/openNotificationSettings.native";
|
|
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
|
|
import { updateNotificationAuthorizationStatus } from "../../../actions/native/PushNotificationActionCreators";
|
|
import NotificationUtils from "../../../utils/native/NotificationUtils";
|
|
import { useIsTeenInStrictCountry } from "../../regional_feature_config/RegionalTeenUtils";
|
|
import { useStateFromStores } from "../../../_bundle/Module589";
|
|
function $mk87417($env) {
|
|
return () => {
|
|
$env.$parent[6].NativePermissionManager.getNotificationAuthorizationStatus().then($mk108155($env));
|
|
};
|
|
}
|
|
function $mk108155($env) {
|
|
return (a0) => {
|
|
if (a0 != null) {
|
|
const r2 = $env.$parent;
|
|
(0, r2[0])(r2[2][10]).updateNotificationAuthorizationStatus(a0);
|
|
}
|
|
(0, $env[0])(true);
|
|
};
|
|
}
|
|
function $mk116246($env) {
|
|
return (a0) => {
|
|
const r1 = $env;
|
|
AnalyticsUtils.track(AnalyticEvents.NOTIFICATION_PERMISSION_PREPROMPT_ACKED, {
|
|
action_type: r1[0],
|
|
action_location: r1[1],
|
|
permission_granted: a0
|
|
});
|
|
(0, r1[2])();
|
|
};
|
|
}
|
|
function $mk116247($env) {
|
|
return (a0) => {
|
|
const r1 = $env;
|
|
AnalyticsUtils.track(AnalyticEvents.PERMISSIONS_ACKED, {
|
|
type: "provisional_notification",
|
|
action: a0 ? "accepted" : "denied"
|
|
});
|
|
NativeModules.NativePermissionManager.getNotificationAuthorizationStatus().then($mk118326(r1));
|
|
};
|
|
}
|
|
function $mk118326($env) {
|
|
return (a0) => {
|
|
if (a0 != null) {
|
|
updateNotificationAuthorizationStatus(a0);
|
|
}
|
|
};
|
|
}
|
|
let $mk87416 = function() {
|
|
return () => PushNotificationPermissionStore.authorizationStatus;
|
|
};
|
|
let env7841 = {};
|
|
export async function requestPushNotificationPermission(c27086_0, c27086_1, c27086_2) {
|
|
let env30410;
|
|
const r25 = env7841;
|
|
let c27086_4 = r25;
|
|
const r11 = env30410 = {
|
|
$parent: r25
|
|
};
|
|
let c27086_3 = r11;
|
|
env30410[0] = c27086_0;
|
|
env30410[1] = c27086_1;
|
|
env30410[2] = c27086_2;
|
|
env30410[3] = void 0;
|
|
env30410[3] = await NativeModules.NativePermissionManager.getNotificationAuthorizationStatus();
|
|
if (env30410[3] === NotificationAuthorizationStatus.DENIED) {
|
|
openNotificationSettings_native();
|
|
AnalyticsUtils.track(AnalyticEvents.NOTIFICATION_PERMISSION_PREPROMPT_ACKED, {
|
|
action_type: EventActionType.TO_SETTINGS,
|
|
action_location: env30410[1]
|
|
});
|
|
(0, env30410[2])();
|
|
} else if (env30410[3] === NotificationAuthorizationStatus.AUTHORIZED) {
|
|
updateNotificationAuthorizationStatus(env30410[3]);
|
|
(0, env30410[2])();
|
|
} else {
|
|
NotificationUtils.requestPermission($mk116246(c27086_3));
|
|
}
|
|
}
|
|
export function useShowReactivationPrompt() {
|
|
const [state, setState] = useState(false);
|
|
useEffect(() => {
|
|
let _shouldShowReactivationPrompts2 = function _shouldShowReactivationPrompts() {
|
|
const r9 = async () => {
|
|
let c31628_0;
|
|
c31628_0 = void 0;
|
|
if (await NativeModules.NativePermissionManager.getNotificationAuthorizationStatus() !== NotificationAuthorizationStatus.AUTHORIZED) {
|
|
(0, setState)(true);
|
|
}
|
|
};
|
|
_shouldShowReactivationPrompts2 = r9;
|
|
return r9.apply(this, arguments);
|
|
};
|
|
(function shouldShowReactivationPrompts() {
|
|
return _shouldShowReactivationPrompts2.apply(this, arguments);
|
|
})();
|
|
}, []);
|
|
return state;
|
|
}
|
|
export async function enableProvisionalPushNotification() {
|
|
const r20 = env7841;
|
|
let c27087_1 = r20;
|
|
let c27087_0 = r20;
|
|
if (await NativeModules.NativePermissionManager.getNotificationAuthorizationStatus() === NotificationAuthorizationStatus.UNDETERMINED) {
|
|
NativeModules.DCDProvisionalNotificationUtils.registerProvisionalNotification($mk116247(c27087_0));
|
|
}
|
|
}
|
|
export function useCanSeePushNotificationNudge() {
|
|
let env18902;
|
|
const r7 = env18902 = {
|
|
$parent: env7841
|
|
};
|
|
const isTeenInStrictCountry = useIsTeenInStrictCountry();
|
|
const stateFromStores = useStateFromStores([PushNotificationPermissionStore], $mk87416());
|
|
const r22 = _slicedToArray(useState(false), 2);
|
|
let r23 = r22[0];
|
|
env18902[0] = r22[1];
|
|
useEffect($mk87417(r7), []);
|
|
if (r23) {
|
|
r23 = !isTeenInStrictCountry;
|
|
}
|
|
if (r23) {
|
|
r23 = stateFromStores != null;
|
|
}
|
|
if (r23) {
|
|
r23 = [NotificationAuthorizationStatus.DENIED, NotificationAuthorizationStatus.PROVISIONAL, NotificationAuthorizationStatus.UNDETERMINED].includes(stateFromStores);
|
|
}
|
|
return r23;
|
|
}
|
|
export function useShouldShowPushNotificationNudgeByPromptType(a0) {
|
|
let env18904;
|
|
const r9 = env18904 = {
|
|
$parent: env7841
|
|
};
|
|
const isTeenInStrictCountry = useIsTeenInStrictCountry();
|
|
const stateFromStores = useStateFromStores([PushNotificationPermissionStore], $mk87416());
|
|
const r22 = _slicedToArray(useState(false), 2);
|
|
let r23 = r22[0];
|
|
env18904[0] = r22[1];
|
|
useEffect($mk87417(r9), []);
|
|
if (r23) {
|
|
r23 = !isTeenInStrictCountry;
|
|
}
|
|
if (r23) {
|
|
r23 = stateFromStores != null;
|
|
}
|
|
if (r23) {
|
|
r23 = [NotificationAuthorizationStatus.DENIED, NotificationAuthorizationStatus.PROVISIONAL, NotificationAuthorizationStatus.UNDETERMINED].includes(stateFromStores);
|
|
}
|
|
const stateFromStores2 = useStateFromStores([PushNotificationPermissionStore], () => PushNotificationPermissionStore.getState().eligiblePromptTypes);
|
|
if (r23) {
|
|
r23 = stateFromStores2.has(a0);
|
|
}
|
|
return r23;
|
|
}
|