Skip to content
This repository was archived by the owner on Mar 9, 2021. It is now read-only.

Commit 22f5c82

Browse files
author
Sean Perkins
committed
Fixes iOS 10 dependency for camera access
1 parent 53ccd4b commit 22f5c82

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

demo/app/App_Resources/iOS/Info.plist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,9 @@
4141
<string>UIInterfaceOrientationLandscapeLeft</string>
4242
<string>UIInterfaceOrientationLandscapeRight</string>
4343
</array>
44+
<key>NSCameraUsageDescription</key>
45+
<string>We need your camera to display your feed.</string>
46+
<key>NSMicrophoneUsageDescription</key>
47+
<string>We need your microphone to hear your voice.</string>
4448
</dict>
4549
</plist>

demo/app/main-view-model.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import {TNSOTSession, TNSOTPublisher, TNSOTSubscriber} from 'nativescript-opento
77

88
export class Demo extends Observable {
99

10-
public _apiKey:string = '45720082';
11-
private _sessionId: string = '1_MX40NTcyMDA4Mn5-MTQ3OTQwMDk0NDcyN35XdmdkZjlnazN2UytPYk1mNW1aWVZSZmh-fg';
12-
private _publisherToken: string = 'T1==cGFydG5lcl9pZD00NTcyMDA4MiZzaWc9YjUxN2NlZmU0MjEyYjU4YTcxMzY0MWU5M2JkZTYyOTIyY2E4OTNhNTpzZXNzaW9uX2lkPTFfTVg0ME5UY3lNREE0TW41LU1UUTNPVFF3TURrME5EY3lOMzVYZG1ka1pqbG5hek4yVXl0UFlrMW1OVzFhV1ZaU1ptaC1mZyZjcmVhdGVfdGltZT0xNDc5NDAwOTU1Jm5vbmNlPTAuOTAzNTUwODk1ODE3Mzk4MyZyb2xlPXB1Ymxpc2hlciZleHBpcmVfdGltZT0xNDgxOTkyOTU0';
10+
public _apiKey:string = '45743242';
11+
private _sessionId: string = '1_MX40NTc0MzI0Mn5-MTQ4MzQwMzM1NzM5N34rUTZFS1JSY0E0Z3hXMXhlYlZYblk5amh-fg';
12+
private _publisherToken: string = 'T1==cGFydG5lcl9pZD00NTc0MzI0MiZzaWc9Y2VkNjE3YmM4NzA0ZWY0M2FjOGNjOWNlMGM3ZWI0MGRjZDI4OWQ1YzpzZXNzaW9uX2lkPTFfTVg0ME5UYzBNekkwTW41LU1UUTRNelF3TXpNMU56TTVOMzRyVVRaRlMxSlNZMEUwWjNoWE1YaGxZbFpZYmxrNWFtaC1mZyZjcmVhdGVfdGltZT0xNDgzNDAzMzY1Jm5vbmNlPTAuMTM1MzI5MjkzNzEwNzEzNTYmcm9sZT1wdWJsaXNoZXImZXhwaXJlX3RpbWU9MTQ4NTk5NTM2Ng==';
1313

1414
private publisher: TNSOTPublisher;
1515
private subscriber: TNSOTSubscriber;
@@ -22,10 +22,10 @@ export class Demo extends Observable {
2222
this.publisher = <TNSOTPublisher> this.page.getViewById('publisher');
2323
this.subscriber = <TNSOTSubscriber> this.page.getViewById('subscriber');
2424
this.session.subscriber = this.subscriber;
25+
this.session.connect(this._publisherToken);
2526
}
2627

2728
publish() {
28-
this.session.connect(this._publisherToken);
2929
this.publisher.publish(this.session, '', 'HIGH', '30');
3030
}
3131

src/ios/publisher.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ export class TNSOTPublisher extends ContentView {
3333
);
3434
this._ios.view.frame = CGRectMake(0, 0, this.width, this.height);
3535
// this._view.frame = CGRectMake(this.originX, this.originY, this.width, this.height);
36+
3637
this._view.addSubview(this._ios.view);
3738

3839
session.events.on('sessionDidConnect', (result) => {
3940
this._ios.publishAudio = true;
41+
let stream: any = result.object;
42+
this.setIdleTimer(true);
4043
try {
41-
let stream: any = result.object;
42-
this.setIdleTimer(true);
4344
stream.publish(this._ios);
4445
} catch(error) {
4546
console.log(error);
@@ -72,13 +73,19 @@ export class TNSOTPublisher extends ContentView {
7273
}
7374

7475
private setIdleTimer(idleTimerDisabled: boolean) {
75-
let app = UIApplication.sharedApplication();
76+
let app: any;
77+
if(UIApplication.sharedApplication) {
78+
app = UIApplication.sharedApplication;
79+
}
80+
else {
81+
app = UIApplication.sharedApplication();
82+
}
7683
app.idleTimerDisabled = idleTimerDisabled;
7784
}
7885

7986
private getCameraResolution(cameraResolution: string): any {
8087
if(cameraResolution) {
81-
switch(cameraResolution.toString().toUpperCase()) {
88+
switch(cameraResolution) {
8289
case 'LOW':
8390
return OTCameraCaptureResolution.OTCameraCaptureResolutionLow;
8491
case 'MEDIUM':

0 commit comments

Comments
 (0)