I am able to add pass received from server to Apple wallet but not getting why pass not getting updated. So, my queries as an iOS developer are:
Who will create pass if it needs to be updated from backend automatically without my iOS app interaction
What is the role of my iOS app in handling pass(adding updating data in Apple Wallet)
Who will register for push notifications after pass added to wallet and who will get push token
At whose end backend or app end this api will be called
Below is my code for adding pass to wallet:
let passURL = URL(string: "https://firebasestorage.googleapis.com/v0/b/iospasswallet.appspot.com/o/pass1.pkpass?alt=media&token=397cb8-d939-4241-b8f8-a1f7e4f8d937")!
// Use URLSession to download pass data asynchronously
let session = URLSession.shared
let task = session.dataTask(with: passURL) { (data, response, error) in
if let error = error {
print("Error downloading pass data: \(error)")
return
}
guard let passData = data else {
print("Failed to get pass data")
return
}
do {
let pass = try PKPass(data: passData)
let passLibrary = PKPassLibrary()
passLibrary.addPasses([pass]) { (status) in
DispatchQueue.main.async {
if status.rawValue == 0 {
print("Pass added successfully")
} else if status.rawValue == 1 {
print("Pass review successfully")
} else {
print("Cancelled Status: \(status.rawValue)")
}
}
}
} catch {
print("Error creating pass: \(error)")
}
}
task.resume()
Thanks in advance.
yourpasshost.example.com
is most likely the same server that you got the pass from, i.e. yours.One key thing to realise is that once a pass is installed, it's independent of how it was installed, and all of your interaction with it from that point occurs via the web service that you have to build according to Apple's spec.