首页 > 解决方案 > Apple Passkit 的 webServiceURL 的 URL 应该是什么

问题描述

我正在为 Apple Passkit 创建凭据。

Apple 提供的示例是用 Ruby 编写的(我不熟悉),它使用端点 /v1/devices/deviceID/registrations/typeID/serial

我在“/v1/devices/:device_id/registrations/:pass_type_id/:serial_number”处用快递写了一个端点

我应该为 Apple Passkit 中的 webServiceURL 使用什么 URL,以便它连接到节点端点。

我使用“webServiceURL”:“https://myapp.com/v1/devices”,

NodeJS 函数是

app.post('/v1/devices/:device_id/registrations/:pass_type_id/:serial_number', async (req, res, next)=>{

这是提供的苹果代码

  post '/v1/devices/:device_id/registrations/:pass_type_id/:serial_number' do
    puts "Handling registration request..."
    # validate that the request is authorized to deal with the pass referenced
    puts "#<RegistrationRequest device_id: #{params[:device_id]}, pass_type_id: #{params[:pass_type_id]}, serial_number: #{params[:serial_number]}, authentication_token: #{authentication_token}, push_token: #{push_token}>"
    if @passes.where(:serial_number => params[:serial_number]).where(:authentication_token => authentication_token).first
      
      puts 'Pass and authentication token match.'
      
      # Validate that the device has not previously registered
      # Note: this is done with a composite key that is combination of the device_id and the pass serial_number
      uuid = params[:device_id] + "-" + params[:serial_number]
      if @registrations.where(:uuid => uuid).count < 1
        
        # No registration found, lets add the device
        @registrations.insert(:uuid => uuid, :device_id => params[:device_id], :pass_type_id => params[:pass_type_id], :push_token => push_token, :serial_number => params[:serial_number])
        
        # Return a 201 CREATED status
        status 201
      else
        # The device has already registered for updates on this pass
        # Acknowledge the request with a 200 OK response
        status 200
      end
      
    else
      # The device did not statisfy the authentication requirements
      # Return a 401 NOT AUTHORIZED response
      status 401
    end

  end

标签: iosnode.jsrubypasskit

解决方案


推荐阅读