Skip to content

Commit

Permalink
Updated to support warm linking
Browse files Browse the repository at this point in the history
  • Loading branch information
nsingh-branch committed Oct 5, 2024
1 parent aebcf24 commit 56e2ebd
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 36 deletions.
24 changes: 12 additions & 12 deletions Branch-Xamarin-SDK.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
<copyright>Copyright 2020 Branch Metrics, Inc.</copyright>
<tags>Xamarin Branch deep linking tracking measurement iOS Android sharing referral invite analytics</tags>
<dependencies>
<group targetFramework="net6.0" >
<group targetFramework="net8.0" >
<dependency id="Newtonsoft.Json" version="13.0.3" />
</group>
<group targetFramework="net6.0-android33" >
<group targetFramework="net8.0-android33" >
<dependency id="Newtonsoft.Json" version="13.0.3" />
<dependency id="Xamarin.Android.Binding.InstallReferrer" version="2.2.0" />
</group>
<group targetFramework="net6.0-ios11.0" >
<group targetFramework="net8.0-ios11.0" >
<dependency id="Newtonsoft.Json" version="13.0.3" />
</group>
</dependencies>
Expand All @@ -32,19 +32,19 @@
<file src="branch_icon.png" target="" />

<!-- Android Binding -->
<file src="BranchSDK.AndroidBinding/bin/Release/net6.0-android/BranchSDK.AndroidBinding.dll" target="lib/net6.0-android33" />
<file src="BranchSDK.AndroidBinding/bin/Release/net6.0-android/BranchSDK.AndroidBinding.xml" target="lib/net6.0-android33" />
<file src="BranchSDK.AndroidBinding/bin/Release/net6.0-android/BranchSDK.AndroidBinding.aar" target="lib/net6.0-android33" />
<file src="BranchSDK.AndroidBinding/bin/Release/net8.0-android/BranchSDK.AndroidBinding.dll" target="lib/net8.0-android33" />
<file src="BranchSDK.AndroidBinding/bin/Release/net8.0-android/BranchSDK.AndroidBinding.xml" target="lib/net8.0-android33" />
<file src="BranchSDK.AndroidBinding/bin/Release/net8.0-android/BranchSDK.AndroidBinding.aar" target="lib/net8.0-android33" />

<!-- iOS Binding -->
<file src="BranchSDK.iOSBinding/bin/Release/net6.0-ios/BranchSDK.iOSBinding.dll" target="lib/net6.0-iOS11.0" />
<file src="BranchSDK.iOSBinding/bin/Release/net6.0-ios/BranchSDK.iOSBinding.resources.zip" target="lib/net6.0-iOS11.0" />
<file src="BranchSDK.iOSBinding/bin/Release/net8.0-ios/BranchSDK.iOSBinding.dll" target="lib/net8.0-iOS11.0" />
<file src="BranchSDK.iOSBinding/bin/Release/net8.0-ios/BranchSDK.iOSBinding.resources.zip" target="lib/net8.0-iOS11.0" />

<!-- Branch SDK -->
<file src="BranchSDK/bin/Release/net6.0-android/BranchSDK.dll" target="lib/net6.0-android33" />
<file src="BranchSDK/bin/Release/net6.0-android/BranchSDK.xml" target="lib/net6.0-android33" />
<file src="BranchSDK/bin/Release/net6.0-ios/BranchSDK.dll" target="lib/net6.0-ios11.0" />
<file src="BranchSDK/bin/Release/net6.0/BranchSDK.dll" target="lib/net6.0" />
<file src="BranchSDK/bin/Release/net8.0-android/BranchSDK.dll" target="lib/net8.0-android33" />
<file src="BranchSDK/bin/Release/net8.0-android/BranchSDK.xml" target="lib/net8.0-android33" />
<file src="BranchSDK/bin/Release/net8.0-ios/BranchSDK.dll" target="lib/net8.0-ios11.0" />
<file src="BranchSDK/bin/Release/net8.0/BranchSDK.dll" target="lib/net8.0" />

</files>
</package>
2 changes: 1 addition & 1 deletion BranchSDK.AndroidBinding/BranchSDK.AndroidBinding.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-android</TargetFramework>
<TargetFramework>net8.0-android</TargetFramework>
<SupportedOSPlatformVersion>24</SupportedOSPlatformVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
2 changes: 1 addition & 1 deletion BranchSDK.iOSBinding/BranchSDK.iOSBinding.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-ios</TargetFramework>
<TargetFramework>net8.0-ios</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
<IsBindingProject>true</IsBindingProject>
Expand Down
14 changes: 7 additions & 7 deletions BranchSDK/BranchSDK.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net6.0-android;net6.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks>net8.0;net8.0-android;net8.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
Expand All @@ -18,21 +18,21 @@
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-ios|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-ios|AnyCPU'">
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-ios|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-ios|AnyCPU'">
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<Reference Include="BranchSDK.AndroidBinding">
<HintPath>..\BranchSDK.AndroidBinding\bin\Release\net6.0-android\BranchSDK.AndroidBinding.dll</HintPath>
<HintPath>..\BranchSDK.AndroidBinding\bin\Release\net8.0-android\BranchSDK.AndroidBinding.dll</HintPath>
</Reference>
<Reference Include="BranchSDK.iOSBinding">
<HintPath>..\BranchSDK.iOSBinding\bin\Release\net6.0-ios\BranchSDK.iOSBinding.dll</HintPath>
<HintPath>..\BranchSDK.iOSBinding\bin\Release\net8.0-ios\BranchSDK.iOSBinding.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
33 changes: 29 additions & 4 deletions BranchSDK/Platforms/Android/BranchAndroid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,12 @@ public static void Init(Android.App.Application app, String branchKey, IBranchSe
instance.branchKey = branchKey;

AndroidNativeBranch.RegisterPlugin(pluginName, pluginVersion);

if (EnableLogging)
{
AndroidNativeBranch.EnableLogging(BranchLogger.BranchLogLevel.Verbose);
}

AndroidNativeBranch.EnableLogging(BranchLogger.BranchLogLevel.Verbose);

instance.lifeCycleHandler = new BranchAndroidLifeCycleHandler(callback);
app.RegisterActivityLifecycleCallbacks(instance.lifeCycleHandler);

Expand Down Expand Up @@ -122,13 +121,12 @@ public static void Init(Android.App.Application app, String branchKey, IBranchBU
instance.branchKey = branchKey;

AndroidNativeBranch.RegisterPlugin(pluginName, pluginVersion);

if (EnableLogging)
{
AndroidNativeBranch.EnableLogging(BranchLogger.BranchLogLevel.Verbose);
}

AndroidNativeBranch.EnableLogging(BranchLogger.BranchLogLevel.Verbose);

instance.lifeCycleHandler = new BranchAndroidLifeCycleHandler(callback);
app.RegisterActivityLifecycleCallbacks(instance.lifeCycleHandler);

Expand Down Expand Up @@ -160,6 +158,33 @@ public override void InitSession(IBranchBUOSessionInterface callback)
.Init();
}

public void ReInitSession(Intent intent, IBranchSessionInterface callback, Activity activity)
{
callbacksList.Clear();
BranchSessionListener obj = new BranchSessionListener(callback);
callbacksList.Add(obj as Object);

activity.Intent = intent;

AndroidNativeBranch.SessionBuilder(activity)
.WithCallback(obj)
.WithData(intent.Data)
.ReInit();
}

public void ReInitSession(Intent intent, IBranchBUOSessionInterface callback, Activity activity)
{
callbacksList.Clear();
BranchBUOSessionListener obj = new BranchBUOSessionListener(callback);
callbacksList.Add(obj as Object);

activity.Intent = intent;

AndroidNativeBranch.SessionBuilder(activity)
.WithCallback(obj)
.WithData(intent.Data)
.ReInit();
}

public override void NotifyNativeInit()
{
Expand Down
18 changes: 13 additions & 5 deletions Timber/Platforms/Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,26 @@ namespace Timber;
* Implement IBranchSessionInterface to get Branch Payloads
*
*/
[Activity(Name = "io.branch.timber.MainActivity", Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
[Activity(Name = "io.branch.timber.MainActivity", Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTask, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity, IBranchSessionInterface
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
LogMessage("BRANCHSDK .NET MAUI: MainActivity.OnCreate still");
BranchAndroid.Init(this, "key_live_nf8w3l1WBpzWdlC00KsLNdmbuEccK6Yr", this);
}

protected override void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);
LogMessage("BRANCHSDK .NET MAUI: MainActivity.OnNewIntent");
BranchAndroid.getInstance().ReInitSession(intent, this, this);
}

public void InitSessionComplete(Dictionary<string, object> data)
{
LogMessage("InitSessionComplete: ");
LogMessage("BRANCHSDK .NET MAUI: InitSessionComplete: ");
foreach (var key in data.Keys)
{
LogMessage(key + " : " + data[key].ToString());
Expand All @@ -45,9 +53,9 @@ public void InitSessionComplete(Dictionary<string, object> data)

public void SessionRequestError(BranchError error)
{
LogMessage("SessionRequestError: ");
LogMessage("Error Message: " + error.ErrorMessage);
LogMessage("Error Code: " + error.ErrorCode);
LogMessage("BRANCHSDK .NET MAUI: SessionRequestError: ");
LogMessage("BRANCHSDK .NET MAUI: Error Message: " + error.ErrorMessage);
LogMessage("BRANCHSDK .NET MAUI: Error Code: " + error.ErrorCode);
}

void LogMessage(string message)
Expand Down
13 changes: 7 additions & 6 deletions Timber/Timber.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks>net8.0-android;net8.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>

<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>Timber</RootNamespace>
<UseMaui>true</UseMaui>
Expand All @@ -30,7 +31,7 @@
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-ios|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-ios|AnyCPU'">
<CreatePackage>false</CreatePackage>
<CodesignProvision>Automatic</CodesignProvision>
<CodesignKey>iPhone Developer</CodesignKey>
Expand All @@ -39,7 +40,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-ios|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-ios|AnyCPU'">
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<PropertyGroup>
Expand All @@ -64,7 +65,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Branch-Xamarin-Linking-SDK" Version="10.0.0" />
</ItemGroup>

Expand Down

0 comments on commit 56e2ebd

Please sign in to comment.