Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define this payload format #50

Open
github-actions bot opened this issue Dec 17, 2022 · 0 comments
Open

define this payload format #50

github-actions bot opened this issue Dec 17, 2022 · 0 comments
Labels

Comments

@github-actions
Copy link

// TODO define this payload format

            await SplashScreen.hideAsync();
        }
        prepare();

        // notification recieved, append to local array
        notificationListener.current = Notifications.addNotificationReceivedListener((notification) => {
            console.log("addNotificationReceivedListener", notification);
            dispatch(pushRecieved(notification));
        });

        // notification response recieved
        responseListener.current = Notifications.addNotificationResponseReceivedListener((response) => {
            console.log("addNotificationResponseReceivedListener", JSON.stringify(response, null, 4));

            // get the notification response data
            // TODO define this payload format
            const responseData = {
                pushIdent: response.notification.request.content.data.pushIdent,
                pushId: response.notification.request.content.data.pushId,
                actionIdentifier: response.actionIdentifier,
                categoryIdentifier: response.notification.request.content.categoryIdentifier,
                responseText: null,
            };

            // asttach user text is defined
            if (response.userText) {
                responseData.responseText = response.userText;
            }

            let foundNotificatonCategory = false;
            for (const index in NotificationDefinitions) {
                const notificationCategory = NotificationDefinitions[index];
                if (index == responseData.categoryIdentifier) {
                    foundNotificatonCategory = notificationCategory;
                }
            }

            // send non-default responses if enabled for this type of notification
            if (response.actionIdentifier == Notifications.DEFAULT_ACTION_IDENTIFIER) {
                if (foundNotificatonCategory && foundNotificatonCategory.sendDefaultAction) {
                    dispatch(setPushResponse(responseData));
                }
            } else {
                dispatch(setPushResponse(responseData));
            }

            // dismiss the notificaqtion when it's tapped
            Notifications.dismissNotificationAsync(response.notification.request.identifier);
        });
@github-actions github-actions bot added the todo label Dec 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants