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

Generate push token #170

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Generate push token #170

wants to merge 3 commits into from

Conversation

doub1ejack
Copy link
Member

This is an experiment in generating the push notification token and saving it to firebase.

Note: this work is not properly tied into RN/Redux. I skipped past redux by hijacking the logout ellipsis and setting an on-click even that would display the token. I wanted to take a real token and play with the expo push notification so I made this work-around. Unfortunately, I haven't gotten to the point where I was able to do anything interesting with it yet.

Following the instructions from here https://docs.expo.io/versions/latest/guides/push-notifications/?redirected
we should be able to generate a push token and display it in an alert dialog.  Then we can
test sending push notifications by using the expo P.N. tool: https://expo.io/dashboard/notifications
Copy link
Member Author

@doub1ejack doub1ejack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some contextual comments.

pushToken: token,
updated: firebase.firestore.FieldValue.serverTimestamp()
});
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this branch uses this function yet.

const PUSH_ENDPOINT = 'https://your-server.com/users/push-token';

export default async function registerForPushNotificationsAsync() {
const { status: existingStatus } = await Permissions.getAsync(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if there's a better place to keep P.N. related stuff. Using the libs dir might make sense if there isn't a more intuitive place.



// POST the token to your backend server from where you can retrieve it to send push notifications.
// return fetch(PUSH_ENDPOINT, {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously we would want to send the token to the server using redux and the appropriate actions.

@@ -162,7 +167,7 @@ class Dashboard extends Component<PropsType> {
}}
>
<TouchableHighlight
onPress={() => this.ellipsisLogoutAlert()}
onPress={() => this.pushTokenAlert()}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how I triggered the push token generation.

@doub1ejack doub1ejack mentioned this pull request Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant