Merge pull request #10 from gustavo-em/finish_broadcast_when_quit_application
Stop broadcast extension when app is closed
This commit is contained in:
commit
866b46fa7c
@ -6,6 +6,7 @@
|
||||
|
||||
import UIKit
|
||||
import bigbluebutton_mobile_sdk
|
||||
import bigbluebutton_mobile_sdk_common
|
||||
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate, RCTBridgeDelegate {
|
||||
@ -36,6 +37,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, RCTBridgeDelegate {
|
||||
return true
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ application: UIApplication) {
|
||||
BigBlueButtonSDK.onAppTerminated()
|
||||
}
|
||||
|
||||
func sourceURL(for bridge: RCTBridge!) -> URL! {
|
||||
//#if DEBUG
|
||||
return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index", fallbackResource:nil)
|
||||
|
@ -12,9 +12,10 @@ open class BBBSampleHandler : RPBroadcastSampleHandler {
|
||||
// Logger (these messages are displayed in the console application)
|
||||
private var logger = os.Logger(subsystem: "BigBlueButtonMobileSDK", category: "BBBSampleHandler")
|
||||
private var appGroupName:String = "";
|
||||
private var createOfferCallObserver:NSKeyValueObservation?;
|
||||
private var setRemoteSDPCallObserver:NSKeyValueObservation?;
|
||||
private var createScreenShareOfferObserver:NSKeyValueObservation?;
|
||||
private var setScreenShareRemoteSDPOBserver:NSKeyValueObservation?;
|
||||
private var addScreenShareRemoteIceCandidateObserver:NSKeyValueObservation?;
|
||||
private var onApplicationTerminatedObserver:NSKeyValueObservation?;
|
||||
private var screenBroadcaster:ScreenBroadcasterService?;
|
||||
|
||||
open func setAppGroupName(appGroupName:String) {
|
||||
@ -36,9 +37,16 @@ open class BBBSampleHandler : RPBroadcastSampleHandler {
|
||||
|
||||
self.screenBroadcaster = ScreenBroadcasterService(appGroupName: appGroupName)
|
||||
|
||||
// Handle quit application to finish broadcast togheter
|
||||
logger.info("Configuring observer for finishApplication")
|
||||
self.onApplicationTerminatedObserver = userDefaults.observe(\.onApplicationTerminated, options: [.new]) { (defaults, change) in
|
||||
self.logger.info("Observer detected a onQuitApplicationWithBroadcastActive request!")
|
||||
finishBroadcastGracefully(self)
|
||||
}
|
||||
|
||||
// Listen for createOffer requests from the UI APP
|
||||
logger.info("Configuring observer for createOffer")
|
||||
self.createOfferCallObserver = userDefaults.observe(\.createScreenShareOffer, options: [.new]) { (defaults, change) in
|
||||
self.createScreenShareOfferObserver = userDefaults.observe(\.createScreenShareOffer, options: [.new]) { (defaults, change) in
|
||||
self.logger.info("Observer detected a createScreenShareOffer request!")
|
||||
|
||||
Task.init {
|
||||
@ -56,7 +64,7 @@ open class BBBSampleHandler : RPBroadcastSampleHandler {
|
||||
}
|
||||
|
||||
logger.info("Configuring observer for setRemoteSDP")
|
||||
self.setRemoteSDPCallObserver = userDefaults.observe(\.setScreenShareRemoteSDP, options: [.new]) { (defaults, change) in
|
||||
self.setScreenShareRemoteSDPOBserver = userDefaults.observe(\.setScreenShareRemoteSDP, options: [.new]) { (defaults, change) in
|
||||
let payload:String = (change.newValue!);
|
||||
// self.logger.info("Observer detected a setScreenShareRemoteSDP request with payload \(payload)")
|
||||
self.logger.info("Observer detected a setScreenShareRemoteSDP request")
|
||||
|
@ -0,0 +1,16 @@
|
||||
//
|
||||
// SampleHandler.h
|
||||
// BigBlueButton Broadcast
|
||||
//
|
||||
// Created by Gustavo Emanuel Farias Rosa on 09/05/22.
|
||||
//
|
||||
|
||||
#ifndef SampleHandler_h
|
||||
#define SampleHandler_h
|
||||
|
||||
#import <ReplayKit/ReplayKit.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
void finishBroadcastGracefully(RPBroadcastSampleHandler * _Nonnull broadcastSampleHandler);
|
||||
|
||||
#endif /* SampleHandler_h */
|
@ -0,0 +1,17 @@
|
||||
//
|
||||
// SampleHandler.m
|
||||
// BigBlueButton Broadcast
|
||||
//
|
||||
// Created by Gustavo Emanuel Farias Rosa on 09/05/22.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "FinishBroadcastService.h"
|
||||
|
||||
void finishBroadcastGracefully(RPBroadcastSampleHandler * _Nonnull broadcastSampleHandler) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wnonnull"
|
||||
[broadcastSampleHandler finishBroadcastWithError:nil];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
@ -14,7 +14,7 @@ Pod::Spec.new do |s|
|
||||
s.source = { :git => "https://github.com/bigbluebutton/bigbluebutton-mobile-sdk.git", :tag => "#{s.version}" }
|
||||
|
||||
s.source_files = "Classes/*.{h,m,mm,swift}"
|
||||
|
||||
s.public_header_files = ["Classes/*.h"]
|
||||
s.dependency "WebRTC-lib"
|
||||
s.dependency "bigbluebutton-mobile-sdk-common"
|
||||
end
|
||||
|
@ -31,6 +31,7 @@ open class BBBSharedData {
|
||||
public static let onScreenShareLocalIceCandidate = "onScreenShareLocalIceCandidate" // Broadcaster -> UI APP
|
||||
|
||||
public static let onScreenShareSignalingStateChange = "onScreenShareSignalingStateChange" // Broadcaster -> UI APP
|
||||
public static let onApplicationTerminated = "onApplicationTerminated" // UI APP -> Broadcaster
|
||||
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,11 @@ extension UserDefaults {
|
||||
return string(forKey: BBBSharedData.SharedData.broadcastStarted) ?? ""
|
||||
}
|
||||
|
||||
// UI APP -> Broadcaster
|
||||
@objc open dynamic var onApplicationTerminated: String {
|
||||
return string(forKey: BBBSharedData.SharedData.onApplicationTerminated) ?? ""
|
||||
}
|
||||
|
||||
// Broadcaster -> UI APP
|
||||
@objc open dynamic var broadcastPaused: String {
|
||||
return string(forKey: BBBSharedData.SharedData.broadcastPaused) ?? ""
|
||||
|
@ -106,4 +106,10 @@ open class BigBlueButtonSDK: NSObject {
|
||||
observer2?.invalidate()
|
||||
}
|
||||
|
||||
public static func onAppTerminated(){
|
||||
BBBSharedData
|
||||
.getUserDefaults(appGroupName: self.appGroupName)
|
||||
.set(BBBSharedData.generatePayload(), forKey: BBBSharedData.SharedData.onApplicationTerminated)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user