Skip to content

Commit

Permalink
ios fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kristian-mkd committed Dec 16, 2024
1 parent 1219bfd commit 317dc24
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 86 deletions.
1 change: 1 addition & 0 deletions packages/client/src/client-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export const setDeviceState = (state: {
thermal: string;
isLowPowerMode: boolean;
}) => {
console.log('🚀 ~ isLowPowerMode:', state.isLowPowerMode);
if (state.os === 'android') {
deviceState = {
oneofKind: 'android',
Expand Down
4 changes: 4 additions & 0 deletions packages/client/src/stats/SfuStatsReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ export class SfuStatsReporter {
this.publisher?.getStats().then(flatten).then(JSON.stringify) ?? '[]',
]);

console.log(
'🚀 ~ SfuStatsReporter ~ run= ~ getDeviceState():',
getDeviceState(),
);
await this.sfuClient.sendStats({
sdk: this.sdkName,
sdkVersion: this.sdkVersion,
Expand Down
78 changes: 0 additions & 78 deletions packages/react-native-sdk/ios/DeviceStats.swift

This file was deleted.

5 changes: 2 additions & 3 deletions packages/react-native-sdk/ios/StreamVideoReactNative.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ -(void)clearObserver {

-(void)startObserving {
hasListeners = YES;
self.hasListeners = YES;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(powerModeDidChange)
name:NSProcessInfoPowerStateDidChangeNotification
Expand All @@ -114,15 +113,15 @@ -(void)stopObserving {
}

- (void)powerModeDidChange {
if (!self.hasListeners) {
if (!hasListeners) {
return;
}
BOOL lowPowerEnabled = [NSProcessInfo processInfo].lowPowerModeEnabled;
[self sendEventWithName:@"isLowPowerModeEnabled" body:@(lowPowerEnabled)];
}

- (void)thermalStateDidChange {
if (!self.hasListeners) {
if (!hasListeners) {
return;
}
NSInteger thermalState = [NSProcessInfo processInfo].thermalState;
Expand Down
10 changes: 5 additions & 5 deletions packages/react-native-sdk/src/providers/StreamCall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,25 +208,25 @@ const DeviceStats = () => {
}

powerModeSubscription = eventEmitter.addListener(
StreamVideoReactNative.POWER_MODE_EVENT,
'isLowPowerModeEnabled',
(isLowPowerMode: boolean) =>
handleLowPowerMode(isLowPowerMode, Platform.OS)
);

if (thermalState === null) {
StreamVideoReactNative.startThermalStatusUpdates().then(
StreamVideoReactNative.currentThermalState().then(
(initialState: string) =>
handleThermalState(initialState, Platform.OS)
);
}

thermalStateSubscription = eventEmitter.addListener(
StreamVideoReactNative.THERMAL_EVENT,
'thermalStateDidChange',
(status: string) => handleThermalState(status, Platform.OS)
);
} else {
eventEmitter.removeAllListeners(StreamVideoReactNative.POWER_MODE_EVENT);
eventEmitter.removeAllListeners(StreamVideoReactNative.THERMAL_EVENT);
eventEmitter.removeAllListeners('isLowPowerModeEnabled');
eventEmitter.removeAllListeners('thermalStateDidChange');
}

return () => {
Expand Down

0 comments on commit 317dc24

Please sign in to comment.