Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Screen Sharing Integration

Updated on 2024-07-30 GMT+08:00
NOTE:

You can share your mobile phone screen with others to improve communication efficiency.

About the Sharing Bundle ID

Bundle ID format of the ScreenShareExtension extension:

Main app bundle ID + ScreenShareExtension

Bundle ID format of the ScreenShareExtensionSetupUI extension:

Main app bundle ID + ScreenShareExtensionSetupUI

Examples:
Assume that the bundle ID of the main app is com.xx.xx.
The bundle ID of the ScreenShareExtension extension will be com.xx.xx.ScreenShareExtension.
The bundle ID of the ScreenShareExtensionSetupUI extension will be com.xx.xx.ScreenShareExtensionSetupUI.

You need to add an iOS extension and configure related code for iOS screen sharing. The following describes how to integrate the SDK to develop the screen sharing extension.

NOTE:

Related features depend on system capabilities. To use the screen sharing function, you need to use iOS 12 or a later version. For more information, see App Extension Programming Guide.

  1. Choose File > New > Target. Then, select the Broadcast Upload Extension template to create an extension target.

    Figure 1 Adding a target
    Figure 2 Selecting the Broadcast Upload Extension template and clicking Next
    Figure 3 Extension named ScreenShareExtension added

  2. Set the iOS version supported by the extension to 12.0.

    Figure 4 Setting the extension
    Figure 5 Setting the extension UI

  3. Add an app group to the main project and current extension, and set the group ID to that obtained in Preparations.

    Figure 6 Default setting (no app groups)
    Figure 7 Choosing TARGETS > Signing & Capabilities > Capability to add an app group
    Figure 8 Choosing App Groups

    Add app groups for ScreenShareExtension and ScreenShareExtensionSetupUI in the same way.

    Figure 9 App groups added

  4. Add app group IDs to the entitlement files. (The group IDs are also used during initialization. You can apply for app group IDs from Apple's official website.)

    Figure 10 App group ID added to an app
    Figure 11 App group ID added to ScreenShareExtension
    Figure 12 App group ID added to ScreenShareExtensionSetupUI

  5. Add HWMExtension.framework to ScreenShareExtension. Go to TARGETS > ScreenShareExtension > Build Settings > Other Linker Flags and add -lc++.

    Figure 13 Choosing ScreenShareExtension > Add Files to...
    Figure 14 Adding HWMExtension.framework to ScreenShareExtension
    Figure 15 Effect after HWMExtension.framework is added to ScreenShareExtension

  6. Configure the screen sharing code. Specifically, add the following code to the SampleHandler.m file of ScreenShareExtension.

    Figure 16 SampleHandler location
    The file can be directly used after the group ID is modified.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    #import "SampleHandler.h"
    #import <HWMExtension/HWMExtension.h>
     
     @interface SampleHandler()<ScreenShareManagerDelegate>
     @property (strong, nonatomic) HWMExensionDataManager *screenShareManager;
     @end
     
     @implementation SampleHandler
     
     - (instancetype)init {
         if (self = [super init]) {
    //         [HWMExtensionAppGroup setAppGroup:@"group.com.huawei.xxx"];// Replace the corresponding value with the app group you obtain.
            self.screenShareManager = [[HWMExensionDataManager alloc] init];
            self.screenShareManager.delegate = self;
         }
         return self;
     }
     
    - (void)dealloc {
        self.screenShareManager = nil;
    }
     
    - (void)broadcastStartedWithSetupInfo:(NSDictionary<NSString *,NSObject *> *)setupInfo {
        // User has requested to start the broadcast. Setup info from the UI extension can be supplied but optional.
        [self.screenShareManager broadcastStartedWithSetupInfo:setupInfo];
    }
     
    - (void)broadcastPaused {
        // User has requested to pause the broadcast. Samples will stop being delivered.
        [self.screenShareManager broadcastPaused];
    }
     
    - (void)broadcastResumed {
        // User has requested to resume the broadcast. Samples delivery will resume.
        [self.screenShareManager broadcastResumed];
    }
     
    - (void)broadcastFinished {
        // User has requested to finish the broadcast.
        [self.screenShareManager broadcastFinished];
    }
     
    - (void)processSampleBuffer:(CMSampleBufferRef)sampleBuffer withType:(RPSampleBufferType)sampleBufferType {
        switch (sampleBufferType) {
            case RPSampleBufferTypeVideo:
                // Handle video sample buffer
                [self.screenShareManager processSampleBuffer:sampleBuffer withType:RPSampleBufferTypeVideo];  
                break;
            case RPSampleBufferTypeAudioApp:
                // Handle audio sample buffer for app audio
                // Audio sharing-related
                if ([self currentIsAudioShare]) {
                    [self.screenShareManager processSampleBuffer:sampleBuffer withType:RPSampleBufferTypeAudioApp];
                }
                break;
            case RPSampleBufferTypeAudioMic:
                // Handle audio sample buffer for mic audio
                break;
                
            default:
                break;
        }
    }
     
    - (void)screenShareManagerFinishBroadcastWithError:(NSError *)error {
        [self.screenShareManager broadcastFinished];
        [self finishBroadcastWithError: error];
    }
    - (BOOL)currentIsAudioShare {
        NSUserDefaults *userDefault = [[NSUserDefaults alloc] initWithSuiteName:[HWMExtensionAppGroup getAppGroup]];
        NSString *audioShareType = [userDefault objectForKey:kHWMExtensionAudioShareKey];
        if ([audioShareType isEqualToString:kHWMExtensionAudioShareValue]) {
            return YES;
        }
        return NO;
    }
     @end
    

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback