Skip to content

Conversation

@mandyJ
Copy link

@mandyJ mandyJ commented Apr 22, 2025

This PR adds support for Android push notifications using PassWallet.

It adds the registration endpoint called by PassWallet;
Adds a migration to add a pushServiceUrl column 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/

@mandyJ mandyJ changed the title Android push notifications Android push notifications with WalletPass Apr 22, 2025
@mandyJ mandyJ changed the title Android push notifications with WalletPass Android push notifications with PassWallet Apr 22, 2025
end

def register_device
device = Passkit::Device.find_or_create_by!(identifier: params[:device_id]) { |d| d.push_token = push_token }
Copy link
Contributor

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
Copy link
Contributor

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"]?

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.

2 participants