I believe I understand from here https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/PassKit_PG/Updating.html#//apple_ref/doc/uid/TP40012195-CH5-SW1 the high-level of how updating a pass is supposed to work. I am able to successfully add the pass to my wallet, and upon adding the pass the wallet app is supposed to send a post request to a URL as specified here https://developer.apple.com/library/content/documentation/PassKit/Reference/PassKit_WebService/WebService.html - I have implemented a route accordingly (im pretty sure!) in rails. In my routes file I have:
post '/v1/devices/:device_id/registrations/:pass_type_id/:serial_number', to: 'test_wallet#register'
and in a controller file called test_wallet_controller.rb I have:
class TestWalletController < ApplicationController
def register
puts "woohoo we're in!"
puts params[:device_id].inspect
render :nothing => true, :status => 200
end
end
The weird thing to me is that when I send a post request manually (like from Postman) I am able to hit that route and log "woohoo we're in!" but when I add a wallet pass to my phone and apple sends a post request my server is logging
ERROR -- : app error: No route matches [POST] "/v1/devices/b842730982707582104b371aea99a73f/registrations/pass.io.impacthealth.users/E5982H-I2" (ActionController::RoutingError)
and from bundle exec rake routes
i have /v1/devices/:device_id/registrations/:pass_type_id/:serial_number(.:format)
pointing to test_wallet#register
(prefixed by POST)
Any help would be insanely greatly appreciated - thanks in advance! And please let me know if there is any other information I can provide that might help debug this :)
Ahh, the problem was that the pass_type_id has some periods in it which were causing rails to interpret the route differently than I had expected (and i had neglected to include periods when i pinged the route via Postman). Looks like it can be handled as seen here https://x3ro.de/rails-3-routing-parameters-with-dots/ .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.