How to create "Add to apple wallet" button using PKAddPassButton for passes with localisation
Asked Answered
T

2

5

In my iOS project I have a screen which allows the user to create apple passes and add it to the wallet. Apple recommends creating "Add to apple wallet" button using PKAddPassButton. When I tried creating apple pass using following code:

let passButton =  PKAddPassButton(addPassButtonStyle: PKAddPassButtonStyle.black)
passButton.frame = CGRect(x:45.0, y: 340.0, width: 320, height: 50)
view.addSubview(passButton)

enter image description here

Button has got couple of issues:

  1. Wallet image is not visible.
  2. Even after changing the language at device level won't localise the text.

Should I use some custom UIButton to achieve this? Any help is appreciated.

Tamarisk answered 11/4, 2018 at 10:52 Comment(0)
T
7

I found the answer, I was testing the code on simulator.When tested the same on device it worked and also localisation is taken care by iOS. If the user changes device language in settings it directly gets reflected in "Add to Apple wallet button".

Tamarisk answered 12/4, 2018 at 13:32 Comment(3)
what about i want to change the locale but not according the device language in settings?Envelopment
In that case you can make use of image assets from apple , check your locale language and create a custom button with corresponding image.Tamarisk
For me as well Wallet image is not visible on the button...Spry
T
1
  1. The wallet image will be visible when running on real device only, it won't come on simulator.
  2. For localisation of this PKAddPassButton, the iOS handles it automatically based on the device language and region settings.
Thurstan answered 4/4, 2022 at 10:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.