Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.7 kB
2
Indexable
Never
 useEffect(() => {
        let eventEmitterSubscription: any;
        let inAppClickedEventEmitterSubscription: any;
        let notificationReceivedEventEmitterSubscription: any;
        SmartechPushReact.addDeepLinkListener(
            SmartechPushReact.SmartechDeeplinkNotification,
            handleDeeplinkWithPayload,
            (eventSubscriptionObject: any) => {
                eventEmitterSubscription = eventSubscriptionObject;
            }
        );
        // // Adding the Smartech Deeplink Notification received Listener
        SmartechPushReact.addCommonListener(
            SmartechPushReact.SmartechNotificationReceived,
            handleOnNotificationReceived,
            (eventSubscriptionObject) => {
                notificationReceivedEventEmitterSubscription = eventSubscriptionObject;
            }
        );

        // Android callback to handle deeplink in terminated/background state.
        SmartechPushReact.getDeepLinkUrl(function (_response: any) {
            setTimeout(() => {
                handleDeeplinkWithPayload(_response);
            }, 2000);
        });

        if (eventEmitterSubscription && inAppClickedEventEmitterSubscription) {
            SmartechPushReact.addCommonListener(SmartechPushReact.SmartechInAppOnClick, handleOnInAppCustomHtmlClick, (eventSubscriptionObject) => {
                inAppClickedEventEmitterSubscription = eventSubscriptionObject;
            });
        }
        return () => {
            eventEmitterSubscription.remove(); // For remove listner
            notificationReceivedEventEmitterSubscription.remove(); // For remove listner
        };
    }, []);
Leave a Comment