11import * as util from "util" ;
22import { EOL } from "os" ;
3- import { PlaygroundStoreUrls } from "./preview-app-constants" ;
43import { exported } from "../../../common/decorators" ;
54
65export class PreviewQrCodeService implements IPreviewQrCodeService {
@@ -10,20 +9,22 @@ export class PreviewQrCodeService implements IPreviewQrCodeService {
109 private $logger : ILogger ,
1110 private $mobileHelper : Mobile . IMobileHelper ,
1211 private $previewSdkService : IPreviewSdkService ,
12+ private $previewSchemaService : IPreviewSchemaService ,
1313 private $qrCodeTerminalService : IQrCodeTerminalService ,
1414 private $qr : IQrCodeGenerator
1515 ) { }
1616
1717 @exported ( "previewQrCodeService" )
1818 public async getPlaygroundAppQrCode ( options ?: IPlaygroundAppQrCodeOptions ) : Promise < IDictionary < IQrCodeImageData > > {
19+ const { projectDir } = options ;
1920 const result = Object . create ( null ) ;
2021
2122 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 ) ) ;
2324 }
2425
2526 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 ) ) ;
2728 }
2829
2930 return result ;
@@ -56,8 +57,8 @@ export class PreviewQrCodeService implements IPreviewQrCodeService {
5657 this . $logger . printMarkdown ( `# Use \`NativeScript Playground app\` and scan the \`QR code\` above to preview the application on your device.` ) ;
5758 this . $logger . printMarkdown ( `
5859To 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 ) } ` ) ;
6162 }
6263 }
6364
@@ -73,5 +74,15 @@ To scan the QR code and deploy your app on a device, you need to have the \`Nati
7374
7475 return url ;
7576 }
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+ }
7687}
7788$injector . register ( "previewQrCodeService" , PreviewQrCodeService ) ;
0 commit comments