This project demonstrates the integration of Communication UI library into Xamarin Forms.
Open CommunicationUI-Proxy.xcworkspace
and in a terminal pod install
.
Build the CommunicationUI-Proxy target for both iphoneos
and iphonesimulator
to build the framework file.
Once you have all the frameworks ready, build FatFramework-Proxy
target. This will merge those architectures into one .framework
file into the Framework folder.
Make a copy of CommunicationUI_Proxy.framework
, so we can work on it safely. Open up a Terminal in the directory that contains the framework and run the below command:
sharpie bind -sdk iphoneos -output ./ -namespace Xam.CommunicationUIProxy.iOS -scope ./CommunicationUI_Proxy.framework/Headers ./CommunicationUI_Proxy.framework/Headers/CommunicationUI_Proxy-Swift.h
Sharpie should now have created new file in the directory ApiDefinitions.cs
.
Open CommunicationUIProxy.Binding.sln
, and copy the CommunicationUI_Proxy.framework
directory into the project and add it as a Native Reference.
Next copy the contents of ApiDefinitions.cs
generated by Sharpie into the /CommunicationUIProxy.Binding/.
folder.
Fix any build issues in the binding library.
At the top of the ApiDefinitions.cs
add using UIKit;
, and remove using CommunicationUI_Proxy;
You should now be able to build the binding library successfully
After building the library you should see a bin
folder where the .dll
files will be generated
Open CommunicationCallingXamarinSampleApp.sln
. Under the CommunicationCallingXamarinSampleApp.iOS/References
right click and Add Reference
. In the .Net Assembly
tab we can browse to where the .dll
of our binding library and add it as a reference.
Now you can including the library into your project by adding using Xam.CommunicationUIProxy.iOS;
at the top of you .cs
files.
The Xamarin library supports all the same features as the native UI composite.
Theming and callback method for error handling is optional and can be set to null
Developers can launch the composite for a group call using a uuid.
GroupCallObjectProxy _groupCallObject = new GroupCallObjectProxy();
_groupCallObject.SetGroupCallProperties(<SOME_UUID>, <YOUR_DISPLAY_NAME>);
_proxy.StartExperienceWithGroupCall(_groupCallObject, <YOUR ACS TOKEN>, null, null);
Teams interop is also supported
TeamsMeetingObjectProxy _teamsMeetingObject = new TeamsMeetingObjectProxy();
_teamsMeetingObject.SetTeamsMeetingsProperties(<TEAMS_URL>, <YOUR_DISPLAY_NAME>);
_proxy.StartExperienceWithTeamsMeeting(_teamsMeetingObject, <YOUR ACS TOKEN>, null, null);
You can assign a new PrimaryColor
and pass it into the StartExperience
method to see the color them changes.
CommunicationThemeProxy customTheme = new CommunicationThemeProxy();
customTheme.PrimaryColor = UIColor.Purple;
_proxy.StartExperienceWithGroupCall(_groupCallObject, acsToken, customTheme, null);
To receive errors from the UI composite, create a method
private void handleError(CommunicationErrorProxy error)
{
Console.WriteLine("handleCall errorCode " + error.Code);
}
In the StartExperience
method pass in this metod like so
_proxy.StartExperienceWithGroupCall(groupCallObject, acsToken, null, (error) => handleError(error));