1
1
import * as util from "util" ;
2
2
import { EOL } from "os" ;
3
- import { PlaygroundStoreUrls } from "./preview-app-constants" ;
4
3
import { exported } from "../../../common/decorators" ;
5
4
6
5
export class PreviewQrCodeService implements IPreviewQrCodeService {
@@ -10,20 +9,22 @@ export class PreviewQrCodeService implements IPreviewQrCodeService {
10
9
private $logger : ILogger ,
11
10
private $mobileHelper : Mobile . IMobileHelper ,
12
11
private $previewSdkService : IPreviewSdkService ,
12
+ private $previewSchemaService : IPreviewSchemaService ,
13
13
private $qrCodeTerminalService : IQrCodeTerminalService ,
14
14
private $qr : IQrCodeGenerator
15
15
) { }
16
16
17
17
@exported ( "previewQrCodeService" )
18
18
public async getPlaygroundAppQrCode ( options ?: IPlaygroundAppQrCodeOptions ) : Promise < IDictionary < IQrCodeImageData > > {
19
+ const { projectDir } = options ;
19
20
const result = Object . create ( null ) ;
20
21
21
22
if ( ! options || ! options . platform || this . $mobileHelper . isAndroidPlatform ( options . platform ) ) {
22
- result . android = await this . getLiveSyncQrCode ( PlaygroundStoreUrls . GOOGLE_PLAY_URL ) ;
23
+ result . android = await this . getLiveSyncQrCode ( this . getGooglePlayUrl ( projectDir ) ) ;
23
24
}
24
25
25
26
if ( ! options || ! options . platform || this . $mobileHelper . isiOSPlatform ( options . platform ) ) {
26
- result . ios = await this . getLiveSyncQrCode ( PlaygroundStoreUrls . APP_STORE_URL ) ;
27
+ result . ios = await this . getLiveSyncQrCode ( this . getAppStoreUrl ( projectDir ) ) ;
27
28
}
28
29
29
30
return result ;
@@ -56,8 +57,8 @@ export class PreviewQrCodeService implements IPreviewQrCodeService {
56
57
this . $logger . printMarkdown ( `# Use \`NativeScript Playground app\` and scan the \`QR code\` above to preview the application on your device.` ) ;
57
58
this . $logger . printMarkdown ( `
58
59
To scan the QR code and deploy your app on a device, you need to have the \`NativeScript Playground app\`:
59
- App Store (iOS): ${ PlaygroundStoreUrls . APP_STORE_URL }
60
- Google Play (Android): ${ PlaygroundStoreUrls . GOOGLE_PLAY_URL } ` ) ;
60
+ App Store (iOS): ${ this . getAppStoreUrl ( options . projectDir ) }
61
+ Google Play (Android): ${ this . getGooglePlayUrl ( options . projectDir ) } ` ) ;
61
62
}
62
63
}
63
64
@@ -73,5 +74,15 @@ To scan the QR code and deploy your app on a device, you need to have the \`Nati
73
74
74
75
return url ;
75
76
}
77
+
78
+ private getGooglePlayUrl ( projectDir : string ) : string {
79
+ const schema = this . $previewSchemaService . getSchemaData ( projectDir ) ;
80
+ return `https://play.google.com/store/apps/details?id=${ schema . scannerAppId } ` ;
81
+ }
82
+
83
+ private getAppStoreUrl ( projectDir : string ) : string {
84
+ const schema = this . $previewSchemaService . getSchemaData ( projectDir ) ;
85
+ return `https://itunes.apple.com/us/app/nativescript-playground/id${ schema . scannerAppStoreId } ?mt=8&ls=1` ;
86
+ }
76
87
}
77
88
$injector . register ( "previewQrCodeService" , PreviewQrCodeService ) ;
0 commit comments