Giter Site home page Giter Site logo

istream's Introduction

Welcome to iStream!

This SwiftUI Framework allows you to add Video Call and Chat to your project within a few lines of code. To use this Framework, you'll need an iOS 15 project. Currently, only Azure Communication Services with a AWS Amplify S3 storage is supported by the framework, but in the future other options are planned.

Installation

To use the framework via Cocoapods, add the following line to your Podfile:


pod iStream, "~> 0.2.0"

Prerequisites

To use the Video Call and Chat feature, you have to create an Azure Communication Services resource. All information you need for the setup can be found here.

Video Call

For the Video Call feature, you'll also need an active Azure Notification Hub resource, which will be used to send and receive push notifications. For the ANH resource you'll need an active Apple Developer Program profile. All infos for the ANH resource can be found here

Note: Make sure to use option 2 with a .p8-Certificate, since only token based authentication will work for the push notifications.

Chat

For the Chat feature, you'll need an active AWS subscription, so the cloud storage for files can be configured. To setup Amplify for your app, follow these instructions:

  1. Navigate in your Xcode project

  2. Configure amplify for your project with:


amplify init

  1. Follow the instructions for the initialization

  2. Add storage to your project with:


amplify add storage

  1. Follow the instructions

  2. After the storage is setup push the changes to the cloud with:


amplify push

  1. Done!

Usage

Video Call

First, import the framework module inside your <YourApp>App.swift:


import iStream

Declare and initialize the CallingViewModel in your <YourApp>App.swift with the following code piece:


@StateObject var callingViewModel: CallingViewModel = CallingViewModel(callingModel: AzureCallingModel())

Then add the viewmodel as an environment object on your root view:


.environmentObject(self.callingViewModel)

After the Viewmodel is initialized, you have to setup the Viewmodel with the initCallingViewModel(identifier:displayName:token:) function. To generate an identifier and a token for the ACS resource, you can use the Azure plattform or implement an own server. Infos about implementing an own server can the found here.

After your viewmodel is initialized, you're ready to make some Video Calls. To start a call, use the self.callingViewModel.startCall(identifier:) function of the CallingViewModel, where identifiershould be an existing identifier from your ACS resource. The property presentCallView: Bool in CallingViewModel is set to true when a call successfully started. With this info, you can use the CallView view, to display the UI. If you want to add custom buttons in the CallView, you can add them in the initializer. Alternative you can implement own Views to display the UI by using the CallingViewModel instance.

Note: The CallView should get the viewmodel passed as an environmentObject with .environmentObject(self.callingViewModel).

Chat

To use the Chat feature, import the framework module in your <YourApp>App.swift file:


import iStream

After that, declare and initialize the ChatViewModel...


@StateObject var chatViewModel: ChatViewModel = ChatViewModel(chatModel: AzureChatModel())

... and pass it ass an environmentObject on your root view:


.environmentObject(self.chatViewModel)

To use the Viewmodel, initialize the chat feature with the self.chatViewModel.initChatViewModel(identifier:displayName:endpoint:token:) function. To generate an identifier and a token for the ACS resource, you can use the Azure plattform or implement an own server. Infos about implementing an own server can the found here. The endpoint parameter is the Endpoint from your ACS resource, which can be found under Settings > Keys in your resource infos in Azure portal.

After your viewmodel is setup, you can use the self.chatViewModel.startChat(with:partnerDisplayName:) function, where identifiershould be an existing identifier from your ACS resource. The chatIsSetup: Bool property is set to true when the chat view can be displayed. You can use this info to show the ChatView, to display the UI. If you want to add a custom message view, you can add it in the initializer. Alternative you can implement own Views to display the UI by using the ChatViewModel instance.

Note: The ChatView should get the viewmodel passed as an environmentObject with .environmentObject(self.chatViewModel).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.