-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: master
Are you sure you want to change the base?
Generate push token #170
Conversation
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
There was a problem hiding this 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() | ||
}); | ||
} |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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, { |
There was a problem hiding this comment.
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()} |
There was a problem hiding this comment.
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.
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.