Skip to content

App is not showing in screensharing popup in iOS #2390

@Muhammad-Ullah

Description

@Muhammad-Ullah

Version of the agora_rtc_engine

6.5.2

Platforms affected

  • Android
  • iOS
  • macOS
  • Windows
  • Web

Steps to reproduce

WhatsApp.Video.2025-07-15.at.6.56.20.PM.mp4

Expected results

It should show the app name when startScreenShare function is called

Actual results

It does not show my app name as shown in the video
https://github.com/user-attachments/assets/dcbbb4e9-f91d-4fc7-8b59-e1396ccf6b6d

Code sample

My app is not showing in popup when user clicks on start screen sharing button,
I have followed the documentation step by step but no luck,
this is my AppDelegate.swift file code,
`import UIKit
import Flutter
import ReplayKit

@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {

let controller = window?.rootViewController as! FlutterViewController
let channel = FlutterMethodChannel(name: "com.zoomapp.screenShare", binaryMessenger: controller.binaryMessenger)

channel.setMethodCallHandler { (call: FlutterMethodCall, result: @escaping FlutterResult) in
  if call.method == "showBroadcastPicker" {
    if #available(iOS 12.0, *) {
      let picker = RPSystemBroadcastPickerView(frame: CGRect(x: 10, y: 100, width: 60, height: 60))
      picker.preferredExtension = "com.zoomapp.zoomapps.AgoraBroadcastExtension"
      picker.showsMicrophoneButton = true

      controller.view.addSubview(picker)
      for view in picker.subviews {
        if let button = view as? UIButton {
          button.sendActions(for: .allTouchEvents)
          break
        }
      }
      result(nil)
    } else {
      result(FlutterError(code: "UNAVAILABLE", message: "iOS version too low", details: nil))
    }
  } else {
    result(FlutterMethodNotImplemented)
  }
}

GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)

}
}`

this is how I am initializing agoraEngine,
Future initAgora() async {
await [Permission.microphone, Permission.camera].request();

_engine = createAgoraRtcEngine();
await _engine.initialize(const RtcEngineContext(appId: AppConfigs.kAppId));

_engine.enableDualStreamMode(enabled: true);

_rtcEngineEventHandler = RtcEngineEventHandler(
  onJoinChannelSuccess: (RtcConnection connection, int elapsed) async {
    debugPrint("local user ${connection.localUid} joined");
    setState(() {
      isJoined = true;
    });
  },
  onUserJoined: (RtcConnection connection, int rUid, int elapsed) async {
    debugPrint("Remote user $rUid joined");

    if (!remoteUids.contains(rUid)) {
      setState(() => remoteUids.add(rUid));
    }
  },
  onUserOffline: (RtcConnection connection, int rUid, UserOfflineReasonType reason) {
  debugPrint("Remote user $rUid left");
  setState(() {
    remoteUids.remove(rUid);
    screenSharingUids.remove(rUid);
    if (pinnedUid == rUid) pinnedUid = null;
  });
},
    onTokenPrivilegeWillExpire: (RtcConnection connection, String token) {
    debugPrint(
        '[onTokenPrivilegeWillExpire] connection: ${connection.toJson()}, token: $token');
  },
  onLocalVideoStateChanged:(VideoSourceType source, LocalVideoStreamState state,
      LocalVideoStreamReason reason){
    print("local screen is sharing=> $state => $reason");

  },
  onRemoteVideoStateChanged: (
      RtcConnection connection,
      int remoteUid,
      RemoteVideoState state,
      RemoteVideoStateReason reason,
      int elapsed,
      ) async {
    print("video screen shared: ${remoteUid}=> $state => $reason");
    if (reason == RemoteVideoStateReason.remoteVideoStateReasonRemoteUnmuted &&
        state == RemoteVideoState.remoteVideoStateDecoding)  {

      final isShared = await getIsScreenShared(
        channelDocId: widget.channelId,
        userId: remoteUid.toString(),
      );

      if (isShared == true) {
        setState(() {
          screenSharingUids.add(remoteUid);
        });
      }
    }

    if (state == RemoteVideoState.remoteVideoStateStopped) {
      setState(() {
        screenSharingUids.remove(remoteUid);
      });
    }
  },
);

_engine.registerEventHandler(_rtcEngineEventHandler);

await _engine.setClientRole(role: ClientRoleType.clientRoleBroadcaster);
await _engine.enableAudio();
await _engine.enableVideo();
// await _engine.setEnableSpeakerphone(true);
// await _engine.enableAudioRecordingOrPlayout(true);
await _engine.setParameters("{\"che.audio.keep.audiosession\":true}");

_engine.loadExtensionProvider(path: 'assets/');
_engine.enableExtension(
  provider: "<The name of the extension provider>",
  extension: "<extensionName>",
  type: MediaSourceType.unknownMediaSource,
  enable: true,
);
_engine.setExtensionProperty(
  provider: "<providerName>",
  extension: "<extensionName>",
  key: "<keyName>",
  value: "<keyValue>",
);
await _engine.startPreview();
String token =
await AgoraHelper().generateToken(widget.channelId, widget.agoraUid);
print("Hi there : $token ${widget.agoraUid}");
await _engine.setAudioProfile(
  profile: AudioProfileType.audioProfileMusicHighQuality,
  scenario: AudioScenarioType.audioScenarioGameStreaming,
);
await _engine.startPreview();
await _engine.joinChannel(
  token: token,
  channelId: widget.channelId,
  uid: widget.agoraUid,
  options: const ChannelMediaOptions(
      publishCameraTrack: true,
      publishMicrophoneTrack: true,
      autoSubscribeAudio: true,
      autoSubscribeVideo: true,
      publishScreenTrack: false,
      enableAudioRecordingOrPlayout: true
  ),
);

}

This is how my MethodChannel is defined,
final MethodChannel _channel = const MethodChannel('com.zoomapp.screenShare');

this function is called when user clicks on sharing screen icon,
` void startScreenShare() async {
if (!isDataInserted) {
await setIsScreenSharedTrue(
channelDocId: widget.channelId, userId: widget.agoraUid.toString());
}

if (Platform.isIOS) {
  await _showBroadcastPicker();
}

try {
  await _engine.startScreenCapture(const ScreenCaptureParameters2(
    captureAudio: true,
    captureVideo: true,
  ));
} catch (e) {
  print('errori: ${e.toString()}');
}

await _engine.startPreview(sourceType: VideoSourceType.videoSourceScreen);
await _engine.updateChannelMediaOptions(const ChannelMediaOptions(
  publishScreenTrack: true,
  publishSecondaryScreenTrack: true,
  publishCameraTrack: false,
  publishMicrophoneTrack: true,
  publishScreenCaptureAudio: true,
  publishScreenCaptureVideo: true,
  clientRoleType: ClientRoleType.clientRoleBroadcaster,
));

isDataInserted = true;

setState(() {
  isScreenShared = true;
  screenSharingUids.add(widget.agoraUid);
});

}
showBroadcastPicker function is this one, Future _showBroadcastPicker() async {
try {
print("Hi there s");
await _channel.invokeMethod('showBroadcastPicker');
} catch (e) {
print('Broadcast picker error: $e');
}
}`

this is my ios/AgoraBroadcastsExtension/Info.plist file code,

`

NSExtension NSExtensionPointIdentifier com.apple.broadcast-services-upload NSExtensionPrincipalClass AgoraReplayKitHandler RPBroadcastProcessMode RPBroadcastProcessModeSampleBuffer `

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
zabi@192 zoomapp % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.29.2, on macOS 15.3.1 24D70 darwin-x64, locale en-PK)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2024.3.5)
[✓] VS Code (version 1.102.0)
[✓] Connected device (4 available)
    ! Error: Browsing on the local area network for muhammadnasir’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network
      as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for apple’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this
      Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for Qarar’s Apple Watch. Ensure the device is unlocked and discoverable via Bluetooth. (code -27)
    ! Error: Browsing on the local area network for iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for Muhammad Dawood i’Phones. Ensure the device is unlocked and attached with a cable or associated with the same local area network
      as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

• No issues found!
zabi@192 zoomapp % 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions