@@ -101,10 +101,10 @@ export class CodePush {
101101
102102 CodePush . cleanPackagesIfNeeded ( ) ;
103103
104- CodePush . notifyApplicationReady ( options . deploymentKey ) ;
104+ CodePush . notifyApplicationReady ( options . deploymentKey , options . serverUrl ) ;
105105
106106 syncCallback && syncCallback ( SyncStatus . CHECKING_FOR_UPDATE ) ;
107- CodePush . checkForUpdate ( options . deploymentKey ) . then (
107+ CodePush . checkForUpdate ( options . deploymentKey , options . serverUrl ) . then (
108108 ( remotePackage ?: IRemotePackage ) => {
109109 if ( ! remotePackage ) {
110110 syncCallback && syncCallback ( SyncStatus . UP_TO_DATE ) ;
@@ -173,17 +173,20 @@ export class CodePush {
173173 ) ;
174174 }
175175
176- static checkForUpdate ( deploymentKey : string ) : Promise < IRemotePackage > {
176+ static checkForUpdate ( deploymentKey : string , serverUrl ?: string ) : Promise < IRemotePackage > {
177177 return new Promise ( ( resolve , reject ) => {
178+ // by default, use our Cloud server
179+ serverUrl = serverUrl || "https://nativescript-codepush-server.herokuapp.com/" ;
180+
178181 const config : Configuration = {
179- serverUrl : "https://nativescript-codepush-server.herokuapp.com/" ,
182+ serverUrl,
180183 appVersion : AppVersion . getVersionNameSync ( ) ,
181184 clientUniqueId : device . uuid ,
182185 deploymentKey
183186 } ;
184187
185188 CodePush . getCurrentPackage ( config ) . then ( ( queryPackage ?: IPackage ) => {
186- new TNSAcquisitionManager ( deploymentKey ) . queryUpdateWithCurrentPackage ( queryPackage , ( error : Error , result : IRemotePackage | NativeUpdateNotification ) => {
189+ new TNSAcquisitionManager ( deploymentKey , serverUrl ) . queryUpdateWithCurrentPackage ( queryPackage , ( error : Error , result : IRemotePackage | NativeUpdateNotification ) => {
187190 if ( error ) {
188191 reject ( error . message || error . toString ( ) ) ;
189192 }
@@ -209,6 +212,7 @@ export class CodePush {
209212 // TODO (low prio) see https://github.com/Microsoft/cordova-plugin-code-push/blob/055d9e625d47d56e707d9624c9a14a37736516bb/www/codePush.ts#L182
210213 // .. or https://github.com/Microsoft/react-native-code-push/blob/2cd2ef0ca2e27a95f84579603c2d222188bb9ce5/CodePush.js#L84
211214 tnsRemotePackage . failedInstall = false ;
215+ tnsRemotePackage . serverUrl = serverUrl ;
212216
213217 resolve ( tnsRemotePackage ) ;
214218 } ) ;
@@ -226,7 +230,8 @@ export class CodePush {
226230 failedInstall : false ,
227231 description : undefined ,
228232 label : undefined ,
229- packageSize : undefined
233+ packageSize : undefined ,
234+ serverUrl : config . serverUrl
230235 } ) ;
231236 } ) ;
232237 }
@@ -241,11 +246,11 @@ export class CodePush {
241246 TNSLocalPackage . clean ( ) ;
242247 }
243248
244- static notifyApplicationReady ( deploymentKey : string ) : void {
249+ static notifyApplicationReady ( deploymentKey : string , serverUrl ?: string ) : void {
245250 if ( CodePush . isBinaryFirstRun ( ) ) {
246251 // first run of a binary from the AppStore
247252 CodePush . markBinaryAsFirstRun ( ) ;
248- new TNSAcquisitionManager ( deploymentKey ) . reportStatusDeploy ( null , "DeploymentSucceeded" ) ;
253+ new TNSAcquisitionManager ( deploymentKey , serverUrl ) . reportStatusDeploy ( null , "DeploymentSucceeded" ) ;
249254
250255 } else if ( ! CodePush . hasPendingHash ( ) ) {
251256 const currentPackageHash = appSettings . getString ( CodePush . CURRENT_HASH_KEY , null ) ;
@@ -255,7 +260,7 @@ export class CodePush {
255260 const currentPackage : ILocalPackage = < ILocalPackage > TNSLocalPackage . getCurrentPackage ( ) ;
256261 if ( currentPackage !== null ) {
257262 currentPackage . isFirstRun = true ;
258- new TNSAcquisitionManager ( deploymentKey ) . reportStatusDeploy ( currentPackage , "DeploymentSucceeded" ) ;
263+ new TNSAcquisitionManager ( deploymentKey , serverUrl ) . reportStatusDeploy ( currentPackage , "DeploymentSucceeded" ) ;
259264 }
260265 }
261266 }
0 commit comments