How to create Firebase Dynamic Links using Maui.iOS? - ios

I'm using .Net Maui with firebase to create a dynamic link for iOS. The error I'm getting is this one:
"Safari can not open this page because address is invalid"
Safari's alert
I entered the team id and created a random app store id, since the app is not deployed on app store. The URL: https://example.page.link/apple-app-site-association, is working just fine.
I added GoogleService-Info.plist in platform directory, iOS folder, just as instructed. I also added apple-app-site-association that looks like this:
{
"applinks": {
"apps": [],
"details": [
{
"appIDs": [ "TeamID.com.companyname.example"],
"paths": [ "NOT /_/*", "/*" ]
}
]
},
"webcredentials": {
"apps": [ "TeamID.com.companyname.example" ]
},
"appclips": {
"apps": [ "TeamID.com.companyname.example" ]
}
}
I don't know if i missed any step until now. Recently I added Entitlements.plist that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:example.page.link</string>
</array>
</dict>
</plist>
With this I should do some sort of provisioning, but the apple account I have needs to be paid for that to work. Is there some tutorial that I can use for Maui with free provisioning? Or am i headed in the wrong direction? Did I miss a step?

Related

MAUI IOS App universal links don't open my application

I am trying to start my MAUI IOS App using URI, but when I clicked on URL that must open my app nothing happen. I set a breakpoint into OpenUrl and ContinueUserActivity to check if its called, but its never called.
I created apple-app-site-association :
{
"applinks": {
"apps": [],
"details": [
{
"appID": "H9375ODJ26.com.example.testapp",
"paths": [ "/video/*"]
}
]
}
}
the file is accessible on https://www.example.com/.well-known/apple-app-site-association and it has content-type = application/json.
I have added in my Entitlements.plist this code:
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:example.com</string>
</array>
In developer.apple.com Associated domains option for my app is turned on.
Can anyone tell me what I'm missing ? I expect when I click on the URI, a pop-up will appear asking how to open the uri - browser or my ios app.
In Maui you can use Launcher to open other applications through URI. Apple requires that you define the schemes you want to use. Add the LSApplicationQueriesSchemes key and schemes to the Info.plist files:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>XXX</string>
</array>
Call the ILauncher.OpenAsync method and pass in a String or Uri representing the application to open:
await Launcher.Default.OpenAsync("xxx");
For more details, refer to:Launcher | Microsoft

Apple app site association not working over AWS CloudFront and S3

Here's my setup:
I have an AWS CloudFront distribution with custom and valid SSL certificate (from ACM)
the CF distribution points to an S3 bucket
My domain example.com is a A record with alias to my CF distribution
I uploaded apple-app-site-association and .well-known/apple-app-site-association to my bucket with the following parameters: Public Read, Content-Type=application/pkcs7-mime
My apple-app-site-association is as follows:
{
"webcredentials": {
"apps": [ "TeamID.BundleId1",
"TeamID.BundleId2" ]
}
}
Of course the values are replaced with my team's ID and the bundle Ids of my 2 apps.
When I run
curl -i https://example.com/apple-app-site-association
or
curl -i https://example.com/.well-known/apple-app-site-association
I have the following result:
HTTP/2 200
content-type: application/pkcs7-mime
content-length: 156
date: Wed, 18 Dec 2019 03:08:15 GMT
last-modified: Wed, 18 Dec 2019 03:04:14 GMT
etag: "redacted"
x-amz-server-side-encryption: AES256
accept-ranges: bytes
server: AmazonS3
x-cache: Miss from cloudfront
via: 1.1 redacted.cloudfront.net (CloudFront)
x-amz-cf-pop: redacted
x-amz-cf-id: redacted
{
"webcredentials": {
"apps": [ "TeamID.BundleId1",
"TeamID.BundleId2" ]
}
}
Which tells me the file is valid and correctly hosted.
On the Xcode side, my target has the following row in Signing & Capabilities > Associated Domains:
webcredentials:example.com
So my entitlements file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.associated-domains</key>
<array>
<string>webcredentials:example.com</string>
</array>
</dict>
</plist>
However when I go to my Sign Up screen on the app, I have the following console log:
[AutoFill] Cannot show Automatic Strong Passwords for app bundleID:
BundleId due to error: Cannot save passwords
for this app. Make sure you have set up Associated Domains for your
app and AutoFill Passwords is enabled in Settings
I am testing on a real device on iOS 13 and AutoFill is enabled.
Note: my app is not live yet (in case I am advised to use the Apple crawler aka App Search API Validation Tool)
Thanks in advance for any help!
From the docs:
Note
If your app runs in iOS 9 or later and you use HTTPS to serve the apple-app-site-association file, you can create a plain text file that uses the application/json MIME type and you don’t need to sign it. If you support Handoff and Shared Web Credentials in iOS 8, you still need to sign the file as described in Shared Web Credentials Reference.
So the content-type: application/pkcs7-mime in your response seems wrong, try changing that to application/json.
I finally managed to get it working. I did 4 different things, I think only 2 of them are important but I'll post them all here in case it helps someone with the same issue.
1: Use my iPhone Developer ID instead of my Team ID (important)
As I was debugging the app on dev environment, the app is signed with my iPhone Developer certificate, not my team's production certificate. So I changed my apple-app-site-association file from
{
"webcredentials": {
"apps": [ "TeamID.BundleId1",
"TeamID.BundleId2" ]
}
}
to
{
"webcredentials": {
"apps": [ "TeamID.BundleId1",
"TeamID.BundleId2",
"iPhoneDeveloperID.BundleId1",
"iPhoneDeveloperID.BundleId2" ]
}
}
2: Invalidate AWS CloudFront cache before testing (important)
While testing, I eventually found out that I was sometimes getting an old version of my apple-app-site-association, depending on which device or software application I was using to fetch it.
So I logged in to the CF console, selected my distribution, selected the Invalidations tab, and created an Invalidation with Object Path /.well-known/apple-app-site-association.
3: Add App Links
I'm not sure whether that made any difference for my issue, as I only invalidated the cache after I tried this, but just in case it helps someone, I decided to add App Links to my app. I added the following object after webcredentials in my apple-app-site-association
"applinks": {
"apps": [],
"details": [
{
"appID": "iPhoneDeveloperID.BundleId1",
"paths": [ "*"]
},
{
"appID": "iPhoneDeveloperID.BundleId2",
"paths": [ "*" ]
},
{
"appID": "TeamID.BundleId1",
"paths": [ "*"]
},
{
"appID": "TeamID.BundleId2",
"paths": [ "*" ]
}
]
}
Make sure the app you're testing is at the top, as the others will get discarded (the first wildcard wins). This must obviously be changed before going to production.
And I added the following entitlement to my app
<string>applinks:example.com</string>
4: Only use .well-known
Again, I don't believe this is important, but instead of having to upload my file twice for each test, I stopped using the root directory, and only uploaded to /.well-known/apple-app-site-association
In case it helps someone else I had similar problem with the file not being valid with correct content type header. I re-uploaded the file using the following:
aws s3 cp --content-type "application/pkcs7-mime" public/.well-known/apple-app-site-association s3://mywebsite/.well-known/

Adding Associated Domains Entitlement For a Flutter App

I need to add Associated Domains Entitlement to my Flutter app, so I can implement App Links.
I use the uni_links plugin which works well for Android. I've added a ios/Runner/Runner.entitlements file as described, but it doesn't work. Apple official docs imply that I need to add something to the app via xcode. Problem is, I don't use xcode, rather Android Studio. I believe I need to manually add an entry to info.plist or project.pbxproj which is what I believe xcode does, however I am not sure what.
Open the Runner.entitlements file from this path :
ios/Runner/Runner.entitlements
And add the applink you want
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- ... other keys -->
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:[YOUR_HOST]</string>
</array>
<!-- ... other keys -->
</dict>
</plist>
For more information, read Apple's guide for Universal Links.
Log in to Apple Developer Account.
Check your bundle Id. Edit your App ID. Add Associated Domain Entitlement from there. Update Provisioning profile and Use it in your Flutter project.

Opening all links from iPhone gmail app opens my app

We have the odd situation where the iPhone app we've developed in Xamarin Forms is somehow intercepting all links in the Gmail app's emails, not just the links we intend our app to process. The user taps any link, and Gmail opens the link directly in our app instead of opening it in chrome or safari.
The only way to prevent this behavior is to go into Gmail settings and set Safari as the default browser.
Is this something that could be caused by an incorrect apple-app-site-association file?
This is the association file we are using for a domain where we process all paths in that domain. Other association files on other domains are more specific (specifying subpaths).
{
"applinks": {
"apps": [],
"details": [
{
"appID": "xxx.yyy",
"paths": [ "/", "" ]
}
]
}
}
We found the solution to the problem. A change had been made to the info.plist file in the iOS project, which caused our app to process Google Chrome links from Gmail. The googlechromes entry was the cause.
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>googlechromes</string>
</array>
</dict>
</array>

iOS: MDM Check-in samples

I am in early stage of Mobile Device Management implementation. I am in process to get iOS Enterprise developer account.I have already started exploring MDM Server implementation.
I need some iOS sample Check-in data which is received from iOS device. These samples are required to understand to write APIs in server side,because these APIs should be common for Blackberry,Android and other mobile platforms.
Once you have an Apple Developer account, log in and go to iOS Provisioning Portal->Certificates->Other and look for the link to the document "Mobile Device Management Protocol Reference". This document explains the structure of a device check-in.
UPDATE (30-Sep-2012): It appears the link text has changed from "Mobile Device Management Protocol Reference" to "Configuration Profile Reference".
You can get step by step all the sample plist in the MDM_Protocol document also.
For example in device check-in process when iOS device receives the push notification from MDM server via APNS then device can respond to MDM Sever as below sample plist format.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Status</key>
<string>Idle</string>
<key>UDID</key>
<string> [ redacted ] </string>
</dict>
</plist>

Resources