App Clip Doesn't Work on First Launch

Hey,

I'm trying to add an App Clip on my application! I use    

Code Block
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {

in order to detect the link. However, this doesn't seem to get called the first time the App Clip is opened. The second time I launch it, it does get called and I'm able to display the appropriate information. I can verify this both by running the app through Xcode with the URL in the App Clip Scheme and also through TestFlgiht.

Moreover, I added

Code Block
<meta name="apple-itunes-app" content="app-id=1479244278, app-clip-bundle-id=com.Swipe4Fave.fave.Clip">

this to my website but the banner with App Clip doesn't show up on an iOS 14 device that doesn't have the app.
Answered by Engineer in 633096022
On first launch, activities are delivered via scene(_:willConnectTo:options:) as part of the connectionOptions. The individual callbacks are only invoked if a new user activity comes in, after the clip has been launched. This is part of UIKit, and the behavior is the same for apps or app clips. You can simplify your own code by forwarding any user activities.

Code Block swift
class MySceneDelegate : NSObject, UISceneDelegate {
    func scene(
        _ scene: UIScene,
        willConnectTo session: UISceneSession,
        options connectionOptions: UIScene.ConnectionOptions
    ) {
        // Do scene connection setup.
        // Then forward any activities.
        for activity in connectionOptions.userActivities {
            scene(scene, continue: activity)
        }
    }
    func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
        // Perform actions with the activity.
    }
}

I'm facing the same issue by passing the url with QR Code
Accepted Answer
On first launch, activities are delivered via scene(_:willConnectTo:options:) as part of the connectionOptions. The individual callbacks are only invoked if a new user activity comes in, after the clip has been launched. This is part of UIKit, and the behavior is the same for apps or app clips. You can simplify your own code by forwarding any user activities.

Code Block swift
class MySceneDelegate : NSObject, UISceneDelegate {
    func scene(
        _ scene: UIScene,
        willConnectTo session: UISceneSession,
        options connectionOptions: UIScene.ConnectionOptions
    ) {
        // Do scene connection setup.
        // Then forward any activities.
        for activity in connectionOptions.userActivities {
            scene(scene, continue: activity)
        }
    }
    func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
        // Perform actions with the activity.
    }
}

Awesome, thanks a lot! Do you have any idea how to get the app clip showing up on my website and on iMessage? When I send a link on iMessage, it still shows up as a regular URL and redirects to the website instead of opening up as an App Clip. Moreover, the website does not show a banner to open up on the website despite the meta code I have above.

I have the URL in the App Clip's App Associated Domains and the Domain URL Status on App Store Connect says validated. But, when I try to add an advanced App Clip experience it says the URL isn't in my associated domains so I'm not sure what I'm missing.


App Clip Doesn't Work on First Launch
 
 
Q