Skip to content

Commit e2ce0cd

Browse files
Feature Request: Version label in the Sync success callback #23
1 parent 42d42e4 commit e2ce0cd

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,12 @@ AppSync.sync({
162162
mandatoryContinueButtonLabel: isIOS ? "Exit now" : "Restart now", // On Android we can kill and restart the app, but on iOS that's not possible so the user has to manually restart it. That's why we provide a different label in this example.
163163
appendReleaseDescription: true // appends the description you (optionally) provided when releasing a new version to AppSync
164164
}
165-
}, (syncStatus: SyncStatus): void => {
165+
}, (syncStatus: SyncStatus, updateLabel?: string): void => {
166166
console.log("AppSync syncStatus: " + syncStatus);
167167
if (syncStatus === SyncStatus.UP_TO_DATE) {
168-
console.log("AppSync: no pending updates; you're running the latest version!");
168+
console.log(`AppSync: no pending updates; you're running the latest version, which is ${updateLabel}`);
169169
} else if (syncStatus === SyncStatus.UPDATE_INSTALLED) {
170-
console.log("AppSync: update installed - it will be activated upon next cold boot");
170+
console.log(`AppSync: update installed (${updateLabel}) - it will be activated upon next cold boot`);
171171
}
172172
});
173173
```
@@ -193,11 +193,11 @@ AppSync.sync({
193193
mandatoryContinueButtonLabel: platform.isIOS ? "Exit now" : "Restart now",
194194
appendReleaseDescription: true // appends the description you (optionally) provided when releasing a new version to AppSync
195195
}
196-
}, function (syncStatus) {
196+
}, function (syncStatus, updateLabel) {
197197
if (syncStatus === SyncStatus.UP_TO_DATE) {
198-
console.log("AppSync: no pending updates; you're running the latest version!");
198+
console.log("AppSync: no pending updates; you're running the latest version, which is: " + updateLabel);
199199
} else if (syncStatus === SyncStatus.UPDATE_INSTALLED) {
200-
console.log("AppSync: update installed - it will be activated upon next cold boot");
200+
console.log("AppSync: update (" + updateLabel + ") installed - it will be activated upon next cold boot");
201201
}
202202
});
203203
```

demo/demoapp/main-view-model.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ export class HelloWorldModel extends Observable {
8181
mandatoryContinueButtonLabel: isIOS ? "Exit now" : "Restart now",
8282
appendReleaseDescription: true // appends the description you (optionally) provided when releasing a new version to AppSync
8383
}
84-
}, (syncStatus: SyncStatus): void => {
84+
}, (syncStatus: SyncStatus, updateLabel?: string): void => {
8585
if (syncStatus === SyncStatus.UP_TO_DATE) {
86-
this.set("message", "AppSync: up to date");
86+
this.set("message", `AppSync: up to date: ${updateLabel}`);
8787
} else if (syncStatus === SyncStatus.UPDATE_INSTALLED) {
88-
this.set("message", "AppSync: update installed");
88+
this.set("message", `AppSync: update installed: ${updateLabel}`);
8989
}
9090
});
9191
}

demo/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"ci.tslint": "npm i && tslint --config '../tslint.json' 'demoapp/**/*.ts' --exclude '**/node_modules/**' --exclude '**/typings/**'"
3232
},
3333
"dependencies": {
34-
"nativescript-app-sync": "file:../publish/package/nativescript-app-sync-1.0.2.tgz",
34+
"nativescript-app-sync": "file:../publish/package/nativescript-app-sync-1.0.3.tgz",
3535
"nativescript-theme-core": "~1.0.4",
3636
"nativescript-unit-test-runner": "^0.3.4",
3737
"tns-core-modules": "~5.4.2"

src/TNSLocalPackage.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class TNSLocalPackage implements ILocalPackage {
2929
failedInstall: boolean;
3030
serverUrl: string;
3131

32-
install(installSuccess: SuccessCallback<InstallMode>, errorCallback?: ErrorCallback, installOptions?: InstallOptions): void {
32+
install(installSuccess: Function, errorCallback?: ErrorCallback, installOptions?: InstallOptions): void {
3333
let appFolderPath = fs.knownFolders.documents().path + "/app";
3434
let unzipFolderPath = fs.knownFolders.documents().path + "/AppSync-Unzipped/" + this.packageHash;
3535
let appSyncFolder = fs.knownFolders.documents().path + "/AppSync";

src/app-sync.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export class AppSync {
144144
this.killApp(false);
145145
};
146146

147-
syncCallback && syncCallback(SyncStatus.UPDATE_INSTALLED);
147+
syncCallback && syncCallback(SyncStatus.UPDATE_INSTALLED, remotePackage.label);
148148

149149
const installMode = options.installMode || InstallMode.ON_NEXT_RESTART;
150150
const mandatoryInstallMode = options.mandatoryInstallMode || InstallMode.ON_NEXT_RESUME;
@@ -182,11 +182,11 @@ export class AppSync {
182182
};
183183

184184
const onDownloadSuccess = (localPackage: ILocalPackage) => {
185-
syncCallback && syncCallback(SyncStatus.INSTALLING_UPDATE);
185+
syncCallback && syncCallback(SyncStatus.INSTALLING_UPDATE, remotePackage.label);
186186
localPackage.install(onInstallSuccess, onError);
187187
};
188188

189-
syncCallback && syncCallback(SyncStatus.DOWNLOADING_PACKAGE);
189+
syncCallback && syncCallback(SyncStatus.DOWNLOADING_PACKAGE, remotePackage.label);
190190

191191
remotePackage.download(
192192
onDownloadSuccess,

src/code-push-lib.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ interface NativeUpdateNotification {
126126
}
127127

128128
interface Callback<T> { (error: Error, parameter: T): void; }
129-
interface SuccessCallback<T> { (result?: T): void; }
129+
interface SuccessCallback<T> { (result: T, updateLabel?: string): void; }
130130
interface ErrorCallback { (error?: Error): void; }
131131

132132
interface Configuration {

src/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-app-sync",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "Use AppSync to hot deploy updates to your app.",
55
"main": "app-sync",
66
"typings": "index.d.ts",

0 commit comments

Comments
 (0)