Can't make Apple Sign In work with Xamarin.Essentials - ios

I know this might not be the best question, not much information, but I will try.
I'm trying to add Apple Sign In to Xamarin.Forms app using Xamarin.Essentials. As of now, I'm just trying to make it work on iOS 13, without going any further yet, server side is not required as I understand for this limited scope.
I looked into the sample app for Xamarin.Essentials, and came to conclusion that specifically for iOS 13 it would be enough to call
await AppleSignInAuthenticator.AuthenticateAsync();
However, I got an exception "com.apple.AuthenticationServices.AuthorizationError error 1000". Couldn't fine more details.
Then I took Xamarin.Essentials sample app, changed Bundle Id to what I have in my app, and then it worked. This validated that certificates and App store were configured correctly.
I tried to get Xamarin.Essentials from GitHub and debug through the library, the exception is in AppleSignInAuthenticator.ios.cs in "PlatformAuthenticateAsync", at the line
var creds = await authManager.Credentials;
Update: In entitlements.plist I added
<key>com.apple.developer.applesignin</key>
<array>
<string>Default</string>
</array>
Any help or advise is appreciated.

I new it would be something stupid.
I have Entitlements.Development.plist and Entitlements.Production.plist. Should I say more (didn't add key for com.apple.developer.applesignin everywhere).
BTW, how people handle it, to have separate value for key aps-environment between development and production?

Related

How debug Universal links

I use the cordova plugin "ionic-plugin-deeplinks" (to my knowledge also works with a plain cordova app).
On Android, links when clicked let users choice between chrome and my application.
=> I suppose that app links works
=> As I'm able to access window.IonicDeeplink and redirect the user to the right page
I'm not able to have the same behavior on iOS, when I click a link I always get the app open in Safari.
How can I find clue on issues ?
More context:
apple-app-site-association is got with a HTTP 200 (over https only), it's located in /.well-known/apple-app-site-association:
I checked TeamID and BundleID 5 times (at least);
with the branch.io validator i get all validations green:
Your domain is valid (valid DNS).
Your file is served over HTTPS.
Your server does not return error status codes greater than 400.
Your file's 'content-type' header was found :)
Your JSON is validated.
with the apple validator, I got : "Action required
Could not extract required information for Universal Links. Learn how to implement the recommended Universal Links.
Error no apps with domain entitlements
The entitlement data used to verify deep link dual authentication is from the current released version of your app. This data may take 48 hours to update." (but some devs said that working app add the same error) what to do with that result?
when monitoring server's log while installing the app with Xcode I see a request get a HTTP 200 on apple-app-site-association
while installing the app with Xcode I got no logs referring to swcd in Xcode (I read here that I should if I had error while installing the app). Is a successful installation silent?
I followed that guide to setup entitlements, but some things feel odd with it:
Unlike the snapshot in the guide, I didn't found any *.entitlements file in my project. Should I have one with cordova? (my xCode seems to remember my setting though). Is it possible to check that installed app get entitlements?
I did set my domain in Xcode like this: applinks:mydomain.com and the switch is ON. But I never uploaded any thing from my local dev environment to apple services. Should I have? If yes, how ?
My current interrogations are highlighted but any explanations on any lack of understanding will be more than welcome!!!
Until then I started a verification for testFlight looking for more info.
while installing the app with Xcode I got no logs referring to swcd in xCode
I implemented Universal Links manually, but situation was similar. Particularly I mentioned empty swcd process log while installing the app, and it turned out that most likely iOS didn't even try to download apple-app-site-association file, like if responsible process wasn't run. In my case device restart helped and deep-linking began to work.
Thus I think restarting device is one another step in troubleshooting when you are sure about all your setup.
For anyone trying to debug this in development:
In XCode, ensure you're editing the Debug version of Signing & Capabilities.
To bypass the Apple Universal Links CDN, configure your Debug domains like applinks:?mode=developer -- adding that query string in development is important.
On your iOS Device, go to Settings->Developer->Universal Links and ensure the Associated Domains Development toggle is switched on.
On your iOS Device in Settings->Developer->Universal Links->Diagnostics, enter your Universal Links URL and ensure you get a green checkmark.
After following all of these steps, Universal Links work locally.

iOS universal links not working?

I'm having trouble getting universal links to work
We have added the json content to our site https://couchsurfing.com/apple-app-site-association
I have double checked that it's using the correct team ID and bundle ID
Universal links is enabled in itunesConnect
running the apple validation fails with the following error:
Error no apps associated with url
I thought maybe the validator doesn't work, but running on iOS 10 device (universal link capability on, with added correct domain to it) clicking a valid link does not trigger the delegate methods in AppDelegate
Any thoughts?
After 3 weeks... It turned out my path was incorrect. My suggestion:
set paths to ["*", "/"] while debugging, get everything to work and test, then as the final step update the path and only include supported paths.
To be more specific the link I was trying to register was
site.com/events/123123 so I would add a path for /events which is wrong that would register site.com/events. I had to register /events/* instead
Also the easiest way to test it is to enter the expected links into the Notes app, because Safari has some weird logic on when links should be handled as deeplink.
Apple's app-site-association validator is useless, it's still failing for me complaining about my App id, when deeplinks actually work. Instead use https://limitless-sierra-4673.herokuapp.com/
I've recently had issues debugging the Universal Link functionality of my app.
I was able to get deep linking to work but it seemed to only work 10% of the time. Since I had just updated to iOS 12, I wanted to make sure there was nothing else I had to do as a developer to ensure the feature worked.
So what was causing intermittent failure?
It seems that iOS has a somewhat strict policy engine for determining when background threads can run.
I was able to observe this by USB tethering to my phone and opening up the debug console for my device
Xcode –> Windows –> Devices & Simulators
Click on device in the left pane
Click Open Console
From there, I was able to filter on "swcd" (SharedWebCredential Daemon). Keeping this console open, I was able to see the daemon at work during app install which is when iOS attempts to pull down the apple-app-site-association file for my app.
As it turns out, dasd (DuetActivitySchedulerDaemon) was failing to run the SharedWebCredential Daemon because my phone had restarted recently, then later it was determined that my phone was too hot...
e.g.
{name: ThunderingHerdPolicy, policyWeight: 1.000, response: {Decision: Must Not Proceed, Score: 0.00, Rationale: [{deviceInUse == 1 AND timeSinceThunderingHerdTriggerEvent < 900}]}}
], FinalDecision: Must Not Proceed}
{name: ThermalPolicy, policyWeight: 5.000, response: {Decision: Absolutely Must Not Proceed, Score: 0.00, Rationale: [{thermalLevel >= 20}]}}
], FinalDecision: Absolutely Must Not Proceed}
Developers beware!
I step through Apple's troubleshooting universal links procedure as already mentioned in other answers.
If still not working, and long-pressing the link in mail or notes app fails to show "Open with [your app]" then try restarting your phone. More than a few times this has been the solution for me!
The Apple validator checks some other things that are not necessary for Universal Links to work, and unfortunately that often results on false positive error messages. The file at https://couchsurfing.com/apple-app-site-association looks good to me, and it passes this validator just fine.
When clicking on a valid link, does the app not open, or just the delegate methods don't fire? These are two very different issues and would have different solutions. There are some troubleshooting steps you could try here, though some of those are specific to the Branch.io (full disclosure: I'm on the Branch team) linking platform.
As some sort of completion to the answers above (took me hours to find out):
The app needs to be installed AFTER you added your "apple-app-site-association" file to the server, as the file initially got fetched / checked after the installation.

Open in "(null)"? dialog in iOS 9

So I'm trying to add a custom URL scheme to my app. Everything works. The confusing part is that when a user gets redirected it puts up a dialog box that says:
Open in "(null)"?
I can't figure out why it says null and not the name of the app. The only other spot I've been able to see this issue mentioned is here:
'Open this page in "null"' Modal appearing from FacebookSDK login after iOS9 and Swift 2 upgrade
but that talks about updating to the latest SDK. It does mention whitelisting the scheme which I tried doing using LSApplicationQueriesSchemes but that doesn't seem to fix it either.
So in my case it ended up being that the following had gotten added to my Info.plist:
<key>CFBundleDisplayName</key>
<string></string>
Either removing this key or giving it a non empty string value fixes the issue and causes it to give: Open in "name of app"?.
The value in that dialog is specified in Build Settings -> Packaging -> Product Name. By any chance, is that field somehow blank? Usually the build should fail if so, and presumably you'd have also noted something wrong on the homescreen, but who knows!
As a side note, URL schemes are not a fool-proof way to handle deep linking anymore, and are actually actively discouraged by Apple. At minimum, you also need to implement Universal Links, but even that is not a complete solution because of variations in how other apps (Facebook, etc) handle outbound links. You may want to consider a tool like Branch.io (full disclosure: I'm on the Branch team) to give a hand with all the logistics.
I found this about whitelisting urlschemes for iOS 9 (found answer here)
Any app built with SDK 9 needs to provide a LSApplicationQueriesSchemes entry in its plist file, declaring which schemes it attempts to query.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>urlscheme</string>
<string>urlscheme2</string>
<string>urlscheme3</string>
<string>urlscheme4</string>
</array>
This worked for me in getting rid of that.

Definite way to make iOS App validation fail?

Sorry, if there is an obvious answer, but I didn't find anything.
Is there a known way to definitely make the App Store validation process (the one while uploading the App) fail but will still work for Ad-Hoc-Distributions? In code, not info.plist configurations or something.
I tried private APIs such as "[UIApplication addStatusBarImageNamed:....]" but they only seem to be checked during the actual review, that's not what I want.
I'm being a bit paranoid about my builds configurations (and using the wrong one for a live submission) and want to have an "assert" style fail option in there that makes sure I don't upload a build created with a wrong configuration.
You could use a different (developer) code signing identity for your "wrong" build configuration. This will make the upload process fail.
Or maybe you could use "invalid" combinations of iOS requirements / supported architectures. For example only support armv7 but minimum require iOS 3.0 - that should be able to compile, but not work on a device.
Add a entitlements file this is signed with a code signing identity of a specific app. Just add this and usually it's not building.

iOS application ExternalHosts

I'm developing an app using phonegap/cordova (1.7.0), I can't figure out how to make my application work with a less restrictive option than *. If I try setting www.mywebservicedomain.com or *.mywebservicedomain.com it can't retrieve data anymore. I see many questions about this and the general answer is to just set *. I'd like to understand how to be more restrictive, if it is possible.
Thank you in advance for your efforts.
That is indeed possible. But be aware that redirects on the servers may lead to connections to different domains which you also have to specifiy. Luckily those restricted accesses appear in the debug log in xcode. Run the project on the simulator or the device from within xcode and then you will see which requests to which servers got blocked.
In the cordova.plist it should look like this:
<key>ExternalHosts</key>
<array>
<string>*.googleapis.com</string>
<string>*.gstatic.com</string>
</array>
I use Google maps in my project which uses the described redirect. Thus I had to add the gstatic although my requests point to maps.googleapis.com originally (I use cordova 1.7).

Resources