branch.io always redirect to App Store on iOS

AndColomboAndColombo ITMember ✭✭

I have added branch.io for deep linking in a xamarin forms project.
On Android it works perfectly but on iOS it aways redirect to App Store.

AppDelegate code:

`public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate, IUNUserNotificationCenterDelegate, IMessagingDelegate
{

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
    App appBUO = new App();
    BranchIOS.Init("My_key_live", options, appBUO);
    LoadApplication(appBUO);
}

// Called when the app is opened via URI scheme
public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
{
    return BranchIOS.getInstance().OpenUrl(url);
}

// Called when the app is opened from a Universal Link 
public override bool ContinueUserActivity(UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
{
    return BranchIOS.getInstance().ContinueUserActivity(userActivity);
}

// Called when the app receives a push notification
public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
{
    BranchIOS.getInstance().HandlePushNotification(userInfo);
}

}`

In my App.cs I have added:

`public partial class App : Application, IBranchBUOSessionInterface
{

public App()
{
    InitializeComponent();

    MainPage = new NavigationPage(new LoginPage());
}

public void InitSessionComplete(BranchUniversalObject buo, BranchLinkProperties blp)
{
    buoModel = new BUOModel();
    buoModel.BUO = buo;
    buoModel.BLP = blp;
}

public void SessionRequestError(BranchError error)
{
    buoModel = null;
}

}`

On a page I placed the share button

`public partial class MyClass : ContentPage, IBranchUrlInterface, IBranchBUOSessionInterface, IBranchIdentityInterface, IBranchLinkShareInterface
{

private void ShareTapped()
{
    universalObject = new BranchUniversalObject();

    universalObject.canonicalIdentifier = "1";
    universalObject.title = "Title";
    universalObject.contentDescription = "description";
    linkProperties = new BranchLinkProperties();
    linkProperties.feature = "";
    linkProperties.channel = null;
    linkProperties.stage = null;
    linkProperties.controlParams.Add("$desktop_url", Constants.BRANCH_IO_PC_URL); 

    Branch.GetInstance().GetShortURL(this, universalObject, linkProperties);

    if (universalObject != null)
    {
        Branch.GetInstance().ShareLink(this, universalObject, linkProperties, "");
    }
}


#region IBranchBUOSessionInterface implementation

public void InitSessionComplete(BranchUniversalObject buo, BranchLinkProperties blp)
{
    var first = buo.ToDictionary();

    var latest = blp.ToDictionary();
}


public void SessionRequestError(BranchError error)
{
}

#endregion

#region IBranchUrlInterface implementation

public void ReceivedUrl(string uri)
{

}

public void UrlRequestError(BranchError error)
{

}

#endregion

#region IBranchLinkShareInterface implementation

public void ChannelSelected(string channel)
{

}

public void LinkShareResponse(string sharedLink, string sharedChannel)
{

}

public void LinkShareRequestError(BranchError error)
{

}


#endregion

#region IBranchIdentityInterface implementation

public void IdentitySet(Dictionary<string, object> data)
{

}

public void LogoutComplete()
{

}

public void IdentityRequestError(BranchError error)
{

}

#endregion

}`

in the info.plist I have added a new url type with identifier:"Branch Scheme", url schemes: "myapp", role:"Editor".
in the entitlements.plist I have check "enable associated domains" and I have added "applinks:myapp.app.link", "applinks:myapp-alternate.app.link".
i have created a new provisioning profile with new capabilities.

In branch dashboard I have check "Always try to open app", "Enable Universal Links" and "I have an iOS App".
My iOS URI Scheme is: "myapp://" and the link domain is: "myapp.app.link".

From the official documentation:
Expected Link Behavior:
Notes - Opens app via Universal Link
iMessage - Opens app via Universal Link

Why the link always redirect to the App Store, even from "Notes" or "iMessage"?

What could be the problem?
Thanks for help.

Sign In or Register to comment.