Swift / iOS launch Apple Pay to a particular payment pass - ios

Searching Apple Pay / Passkit / Wallet documentation, I've found very few code examples and pretty poor documentation. We're attempting to present a payment pass we've provisioned rather than just launch the wallet with openPaymentSetup().
According to PKPassLibrary docs, this can be achieved with PKPassLibrary.present(). We're invoking this function and it launches Apple Pay directly into the add a card wizard, which seems worse than the UX from openPaymentSetup().
The code we're using is:
let library: PKPassLibrary = PKPassLibrary()
let passes: [PKPass] = library.remotePaymentPasses()
if !passes.isEmpty, #available(iOS 10.0, *) {
library.present(passes[passes.count-1].paymentPass!)
} else {
library.openPaymentSetup()
}
We get the pass library and our passes, then conditionally attempt to present the last pass.
Does anyone know how to show a pass rather than launching a tutorial or add a card wizard?

You can still use presentPaymentPass api to present a PaymentPass. But your iOS version should be >=10.3.3 even if Apple Documentation says iOS version > 10.0. This is a wrong documentation from Apple.

Related

Xamarin forms how to log in with Apple account

I'm trying to publish my first xamarin forms app on IOS. I barred the issue of login with the Apple account.
I have 4 questions, please.
1- If I implement Sign in with Apple only for IOS 13+ will it be accepted? :(
2- I'm trying to use Xamarin Essentials to log in to IOS 13+ as shown in this article:
Xamarin Essentials
// Use Native Apple Sign In API's
r = await AppleSignInAuthenticator.AuthenticateAsync();
But I only get back the idToken. AccessToken, name and mail return null. Am I missing something?
3 - And finally I tried to use the plugin.firebaseAuth version 4.0.0-pre01:
Link plugin
// For iOS
var credential = CrossFirebaseAuth.Current.OAuthProvider.GetCredential("apple.com", idToken, rawNonce: rawNonce);
var result = await CrossFirebaseAuth.Current.Instance.SignInWithCredentialAsync(credential);
// For Android
var provider = new OAuthProvider("apple.com");
var result = await CrossFirebaseAuth.Current.Instance.SignInWithProviderAsync(provider);
It provides an example using prism to deal with this, but when I install the plugin in this version the application is no more than a splash screen and closes, without showing an error in the output. What am I doing wrong? :(
The first link seems promising for iOS less than 13 and Android using Asp.NET. However in the application I use only the Firebase ClouFirestone and Firebase Hosting for the Administrative Panel. Is it possible for me to sign in Apple without the services of a different backend?
I am very grateful for any light on the path I must follow
1- If I implement Sign in with Apple only for IOS 13+ will it be accepted?
It depends, if they don't find any other issues or violation, it will get accepted.
2- I'm trying to use Xamarin Essentials to log in to IOS 13+ as shown in this article: But I only get back the idToken.
Apple will only provide you the requested details on the first authentication. After that first authentication, you will only get the User Id so be sure to store the details that first time in case you need them.
This feature needs to be tested on a physical device running iOS 13. The simulator is not reliable, it doesn’t always work properly.
Should follow the design guidelines when implementing Apple Sign In. You can find it here: https://developer.apple.com/design/human-interface-guidelines/sign-in-with-apple/overview/

PassKit Pass - Opening iOS app from a pass

I noticed a few PassKit wallet passes can open their originating app, right from the pass. The iOS app opens when the pass icon is clicked, for example in Delta Airlines passes.
I can't seem to find any documentation or examples on this. How can one add this to a PKPass?
You can use the appLaunchURL key in the passes’ pass.json.
https://developer.apple.com/library/archive/documentation/UserExperience/Reference/PassKit_Bundle/Chapters/TopLevel.html#//apple_ref/doc/uid/TP40012026-CH2-SW1

How to disable "turn-to-sleep" on Apple Watch?

I'm working for an airline with their app. We have released the app on Apple Watch, but have a big problem: the scanners for the QR-code used to go through security and to board the plane, are scanning from the bottom and up...
This means that you cannot use the watch app, because when you turn your wrist, the watch goes in black sleep mode.
Is there any way of turning this temporarily off for a view? I have heard rumours that it can be disabled in WatchOS 4, but can't find out how.
Thanks for the help! :)
This is very interesting question. There seems no way to present this without the PassKit(Or even with passkit the screen will still go off...) I think PassKit Controller has some functions when you focus the QR code it doesn't go to sleep...
reading the watchkit reference in here , you need to implement presentation of the passkitController.
Because right now you cannot tell apple watch to resign sleep, it is agains human guidelines + it would really be energy-consuming solution. Instead, apple handles for you with PassKitController instance. So on watchkit, you do this:
let pass = PKPass(data: /*There goes your data*/, error: nil)
presentAddPassesController(withPasses: [pass]) {
// Do smth on completion
}
You definitely should try to inform user and give him access to export the pkpass to wallet...
Resources used:
https://github.com/TwoRingSoft/pkpassgenerator
For generating custom passkit object
This could help you as well:
https://www.natashatherobot.com/url-apple-wallet-passkit-pass/?utm_campaign=This%2BWeek%2Bin%2BSwift&utm_medium=email&utm_source=This_Week_in_Swift_138

How to open app store in ios app?

I'm using this code to rate app from an ios application.
let appLink = "https://itunes.apple.com/us/app/[name of the app]/id[idnumber]?mt=8"
let url = URL(string: appLink)
UIApplication.shared.openURL(url!)
the problem is Safari says "the page address is invalid"
Is there any way to make it work? I'm using xcode 9 and swift 4
Your URL can simply be:
https://itunes.apple.com/app/id<App ID Here>?mt=8
Better yet, use SKStoreProductViewController so you can show the app in an App Store page without the need to leave your app.
And as of iOS 10.3 you can SKStoreReviewController specifically to allow a user to post a review or rate an app.
Use the STORE KIT request review based on the new guidelines and documentation found here.
https://developer.apple.com/documentation/storekit/skstorereviewcontroller/2851536-requestreview
On older version you can use
itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=<AppId>&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software

Undocumented method to find sim card availability in ios?

I have found an undocumented method for detecting sim card availability in iphone. This method needs CoreTelephony.framework
NSString * CTSIMSupportGetSIMStatus();
int CTGetSignalStrength();
NSString *status = CTSIMSupportGetSIMStatus();
NSLog(#"Sim card status %#",status);
This method works well. can i use this method in my project? If i use this undocumented method, will apple reject my app? plz let me know... Thanks
You can not use undocumented method as Apple says that they can change the implementation for bug fixing or by updating the SDK cause App crash. They do not allow the use of Private API and trace at submission at store. Mostly private method can be found in debugging at Xcode and start with _Underscore so you can try alternative to achieving things if you do not want to get reject your application later at submission.

Resources