-
-
Notifications
You must be signed in to change notification settings - Fork 30
Android push notifications with PassWallet #40
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
base: main
Are you sure you want to change the base?
Conversation
| end | ||
|
|
||
| def register_device | ||
| device = Passkit::Device.find_or_create_by!(identifier: params[:device_id]) { |d| d.push_token = push_token } |
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.
In the previous version, no changes are made to the db a device is found. Now, the device is being updated every time.
Maybe like this to back fill missing push_service_url?
device = Passkit::Device.find_or_create_by!(identifier: params[:device_id]) do |d|
d.push_service_url = push_service_url
d.push_token = push_token
end
device.update(push_service_url: push_service_url) if device.push_service_url.blank?
| def push_service_url | ||
| return unless request&.body | ||
|
|
||
| request.body.rewind |
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 looks fairly atypical. Can you not acccess it with params["pushServiceUrl"]?
This PR adds support for Android push notifications using PassWallet.
It adds the registration endpoint called by PassWallet;
Adds a migration to add a
pushServiceUrlcolumn to the Devices table;Registers an Android device with its
pushServiceUrl. The presence of a pushServiceUrl indicates if the device is Android vs iOS.If iOS, a library like apnotic can be used to send an Apple Push Notification, as demonstrated here
if Android, a POST request can be made to the pushServiceUrl as laid out by PassWallet documentation.
Why PassWallet?
While coorasse/passkit defaults to WalletPasses to open the Apple wallet format (.pkpass) on Android, I have found that WalletPasses does not support the multiple pass format (.pkpasses), but PassWallet does.
PassWallet supports adding passes by adding from file storage on the mobile device, which has made development a lot easier; PassWallet appears to be more feature rich in general compared to WalletPasses.
I also found the PassWallet developer documentation to be more descriptive: https://github.com/Kwiket/passwallet
compared to WalletPasses: https://walletpasses.io/developer/