简体   繁体   English

注册Apple Wallet Pass以获得推送通知

[英]Registering Apple Wallet Pass for push notifications

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. 我相信我从这里https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/PassKit_PG/Updating.html#//apple_ref/doc/uid/TP40012195-CH5-SW1了解应该如何更新通行证。 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. 我能够成功地将通行证添加到我的钱包,并且在添加通行证后,钱包应用程序应该向此处指定的URL发送发帖请求https://developer.apple.com/library/content/documentation/PassKit /Reference/PassKit_WebService/WebService.html-我已经在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: 在名为test_wallet_controller.rb的控制器文件中,我有:

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!" 对我来说,很奇怪的是,当我手动发送一个发帖请求(例如来自Postman的发帖请求)时,我能够打那条路线并登录“ woohoo we we 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) 并从bundle exec rake routes我有/v1/devices/:device_id/registrations/:pass_type_id/:serial_number(.:format)指向test_wallet#register (由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). 嗯,问题在于pass_type_id中包含一些句点,这导致Rails对路线的解释与我预期的不同(并且我忽略了当我通过Postman ping路线时包含的句点)。 Looks like it can be handled as seen here https://x3ro.de/rails-3-routing-parameters-with-dots/ . 看起来可以处理,如https://x3ro.de/rails-3-routing-parameters-with-dots/所示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM