Skip to content

MAUI-iOS binding and sample project building #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dotnet MAUI support for Android and iOS is a work in progress. Current status:

* Android: Meeting SDK Version: 5.15.10.1778 [![AndroidMauiNugetShield]][AndroidMauiNugetLink]

- [ ] iOS: Not yet supported, in progress.
* iOS: MobileRTC Version: 5.15.7.9685

# Xamarin.Forms

Expand Down
47 changes: 47 additions & 0 deletions src/MAUI/SampleApp/Platforms/iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;

using Foundation;
using ObjCRuntime;
using UIKit;

namespace ZoomSDKSampleApp.iOS
{
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to
// application events from iOS.
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());

Runtime.MarshalManagedException += (object sender, MarshalManagedExceptionEventArgs args) =>
{
Console.WriteLine("Marshaling managed exception");
Console.WriteLine(" Exception: {0}", args.Exception);
Console.WriteLine(" Mode: {0}", args.ExceptionMode);

};
Runtime.MarshalObjectiveCException += (object sender, MarshalObjectiveCExceptionEventArgs args) =>
{
Console.WriteLine("Marshaling Objective-C exception");
Console.WriteLine(" Exception: {0}", args.Exception);
Console.WriteLine(" Mode: {0}", args.ExceptionMode);
};

return base.FinishedLaunching(app, options);
}
}
}

7 changes: 7 additions & 0 deletions src/MAUI/SampleApp/Platforms/iOS/Entitlements.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?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>
</dict>
</plist>

46 changes: 46 additions & 0 deletions src/MAUI/SampleApp/Platforms/iOS/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?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>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>MinimumOSVersion</key>
<string>15.0</string>
<key>CFBundleDisplayName</key>
<string>ZoomSDKSampleApp</string>
<key>CFBundleIdentifier</key>
<string>com.companyname.ZoomSDKSampleApp</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>CFBundleName</key>
<string>ZoomSDKSampleApp</string>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/AppIcon.appiconset</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>We will use your Bluetooth to access your Bluetooth headphones.</string>
<key>NSCameraUsageDescription</key>
<string>For people to see you during meetings, we need access to your camera.</string>
<key>NSMicrophoneUsageDescription</key>
<string>For people to hear you during meetings, we need access to your microphone.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>For people to share, we need access to your photos</string>
</dict>
</plist>
29 changes: 29 additions & 0 deletions src/MAUI/SampleApp/Platforms/iOS/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;

using Foundation;
using UIKit;

namespace ZoomSDKSampleApp.iOS
{
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
try
{
UIApplication.Main(args, null, typeof(AppDelegate));
}
catch (Exception ex) {
Console.WriteLine($"Managed Exception Caught: {ex}");
}


}
}
}

113 changes: 113 additions & 0 deletions src/MAUI/SampleApp/Platforms/iOS/iOSZoomSDKService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
using System;
using System.Threading.Tasks;
using SampleApp;
using Zoomios;

[assembly: Dependency(typeof(ZoomSDKSampleApp.iOS.iOSZoomSDKService))]
namespace ZoomSDKSampleApp.iOS
{
public class iOSZoomSDKService : IMobileRTCMeetingServiceDelegate, IZoomSDKService
{
private bool inMeeting;
private MobileRTCAuthService authService;

public override void OnMeetingStateChange(MobileRTCMeetingState state)
{
if (state == MobileRTCMeetingState.Ended)
{
//The meeting has ended
//=> Fire your event!
}
if (state == MobileRTCMeetingState.InMeeting)
{
inMeeting = true;
}
else
{
inMeeting = false;
}
}

public async Task<bool> InitZoomLib(string jwtToken)
{
bool InitResult = false; ;

await Device.InvokeOnMainThreadAsync(() =>
{
InitResult = MobileRTC.SharedRTC.Initialize(new MobileRTCSDKInitContext
{
EnableLog = true,
Domain = "https://zoom.us",
Locale = MobileRTC_ZoomLocale.Default
});
if (InitResult)
{
MobileRTC.SharedRTC.SetLanguage("en");
authService = MobileRTC.SharedRTC.GetAuthService();
if (authService != null)
{
authService.Delegate = new MobileDelegate(); //inherits from MobileRTCAuthDelegate
authService.JwtToken = jwtToken;
authService.SdkAuth();
}
Console.WriteLine($"Mobile RTC Version: {MobileRTC.SharedRTC.MobileRTCVersion()} ");
}
});

return InitResult;
}

public bool IsInitialized()
{
bool result = false;

if (MobileRTC.SharedRTC != null)
{
if (MobileRTC.SharedRTC.IsRTCAuthorized())
{
if (MobileRTC.SharedRTC.GetMeetingService() != null)
{
result = true;
}
}
}
return result;
}

public async Task JoinMeeting(string meetingID, string meetingPassword, string displayName = "Zoom Demo")
{
if (IsInitialized())
{
var meetingService = MobileRTC.SharedRTC.GetMeetingService();
meetingService.Init();
meetingService.Delegate = this;

MobileRTCMeetingJoinParam meetingParamDict = new MobileRTCMeetingJoinParam();
meetingParamDict.UserName = displayName;
meetingParamDict.MeetingNumber = meetingID;
meetingParamDict.Password = meetingPassword;

MobileRTCMeetingSettings settings = MobileRTC.SharedRTC.GetMeetingSettings();
settings.DisableDriveMode(true);
settings.EnableCustomMeeting = false;
//Specify your meeting options here

var meetingJoinResponse = await Device.InvokeOnMainThreadAsync(() =>
{
return meetingService.JoinMeetingWithJoinParam(meetingParamDict);
});

Console.WriteLine($"Meeting Joining Response {meetingJoinResponse}");
}
}
}

class MobileDelegate : MobileRTCAuthDelegate
{
public override void OnMobileRTCAuthReturn(MobileRTCAuthError returnValue)
{
Console.WriteLine($"Another Log from our iOS counterpart: {returnValue}");
}
}
}

16 changes: 8 additions & 8 deletions src/MAUI/SampleApp/SampleApp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0-android;</TargetFrameworks>
<TargetFrameworks>net7.0-android;net7.0-ios;</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> -->
<OutputType>Exe</OutputType>
Expand All @@ -21,7 +21,7 @@
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">23.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
Expand Down Expand Up @@ -52,13 +52,10 @@
<PackageReference Include="Mobile.BuildTools" Version="2.0.245" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Android\Lottie.Android\Lottie.Android.csproj" />
<ProjectReference Include="..\Android\MobileRTC.MAUI\MobileRTC.MAUI.csproj" />
<ProjectReference Include="..\Android\ZoomCommonLib.MAUI\ZoomCommonLib.MAUI.csproj" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
<ProjectReference Include="..\Android\ZoomCommonLib.MAUI\ZoomCommonLib.MAUI.csproj" />
<ProjectReference Include="..\Android\Lottie.Android\Lottie.Android.csproj" />
<ProjectReference Include="..\Android\MobileRTC.MAUI\MobileRTC.MAUI.csproj" />
<PackageReference Include="Xamarin.AndroidX.Security.SecurityCrypto" Version="1.1.0.1-alpha06" />
<PackageReference Include="Xamarin.Google.Crypto.Tink.Android" Version="1.10.0" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Core" Version="2.19.1" />
Expand All @@ -84,5 +81,8 @@
<PackageReference Include="Xamarin.AndroidX.Lifecycle.Runtime.Ktx" Version="2.6.1.3" />
<PackageReference Include="Xamarin.AndroidX.Fragment.Ktx" Version="1.6.1" />
</ItemGroup>
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
<ProjectReference Include="..\iOS\MobileRTC.iOS\MobileRTC.iOS.csproj" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions src/MAUI/ZoomSDK.MAUI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
buildtools.json = buildtools.json
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MobileRTC.iOS", "iOS\MobileRTC.iOS\MobileRTC.iOS.csproj", "{795905AF-09C4-4C0E-8F1B-E6346B03CA03}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -40,6 +42,10 @@ Global
{819C96ED-06C7-47B7-A5B7-C5AEE52D5BDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{819C96ED-06C7-47B7-A5B7-C5AEE52D5BDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{819C96ED-06C7-47B7-A5B7-C5AEE52D5BDA}.Release|Any CPU.Build.0 = Release|Any CPU
{795905AF-09C4-4C0E-8F1B-E6346B03CA03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{795905AF-09C4-4C0E-8F1B-E6346B03CA03}.Debug|Any CPU.Build.0 = Debug|Any CPU
{795905AF-09C4-4C0E-8F1B-E6346B03CA03}.Release|Any CPU.ActiveCfg = Release|Any CPU
{795905AF-09C4-4C0E-8F1B-E6346B03CA03}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading