Skip to content

Commit eb242fa

Browse files
committed
modifications and added readme
modifications and added readme
1 parent d94ba8f commit eb242fa

File tree

3 files changed

+156
-1
lines changed

3 files changed

+156
-1
lines changed

README.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# cordova-code-push + Ionic example
2+
3+
## Prepare the Ionic APP
4+
5+
`ionic start codepush-ionic-test blank`
6+
7+
`cd codepush-ionic-test`
8+
9+
`ionic cordova plugin add cordova-plugin-code-push`
10+
11+
`sudo npm install --save @ionic-native/code-push`
12+
13+
`ionic cordova platform add ios`
14+
15+
`ionic cordova platform add android`
16+
17+
## Code push set up
18+
19+
`sudo npm install`
20+
21+
`sudo npm install -g code-push-cli`
22+
23+
`code-push login`
24+
25+
`code-push app add codepush-ionic-test-ios ios cordova`
26+
27+
`code-push app add codepush-ionic-test-android android cordova`
28+
29+
**See again the keys:**
30+
31+
`code-push deployment ls codepush-ionic-test-android -k`
32+
33+
`code-push deployment ls codepush-ionic-test-ios -k`
34+
35+
**config.xml**:
36+
```xml
37+
<platform name="android">
38+
<preference name="CodePushDeploymentKey" value="YOUR-ANDROID-DEPLOYMENT-KEY" />
39+
</platform>
40+
<platform name="ios">
41+
<preference name="CodePushDeploymentKey" value="YOUR-IOS-DEPLOYMENT-KEY" />
42+
</platform>
43+
```
44+
45+
**src/app/app.module.ts** (set `CodePush` as provider):
46+
47+
```typescript
48+
import { BrowserModule } from '@angular/platform-browser';
49+
import { ErrorHandler, NgModule } from '@angular/core';
50+
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
51+
import { SplashScreen } from '@ionic-native/splash-screen';
52+
import { StatusBar } from '@ionic-native/status-bar';
53+
54+
import { MyApp } from './app.component';
55+
import { HomePage } from '../pages/home/home';
56+
57+
import { CodePush } from '@ionic-native/code-push';
58+
59+
@NgModule({
60+
declarations: [
61+
MyApp,
62+
HomePage
63+
],
64+
imports: [
65+
BrowserModule,
66+
IonicModule.forRoot(MyApp)
67+
],
68+
bootstrap: [IonicApp],
69+
entryComponents: [
70+
MyApp,
71+
HomePage
72+
],
73+
providers: [
74+
StatusBar,
75+
SplashScreen,
76+
CodePush,
77+
{provide: ErrorHandler, useClass: IonicErrorHandler}
78+
]
79+
})
80+
export class AppModule {}
81+
82+
```
83+
84+
**src/app.component.ts** (alert for **updates**):
85+
86+
```typescript
87+
import { Component } from '@angular/core';
88+
import { Platform } from 'ionic-angular';
89+
import { StatusBar } from '@ionic-native/status-bar';
90+
import { SplashScreen } from '@ionic-native/splash-screen';
91+
92+
import { HomePage } from '../pages/home/home';
93+
94+
import { CodePush, InstallMode, SyncStatus } from '@ionic-native/code-push';
95+
import { AlertController } from 'ionic-angular/components/alert/alert-controller';
96+
97+
@Component({
98+
templateUrl: 'app.html'
99+
})
100+
export class MyApp {
101+
rootPage:any = HomePage;
102+
103+
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen,
104+
private codePush: CodePush, private alertCtrl: AlertController) {
105+
platform.ready().then(() => {
106+
// Okay, so the platform is ready and our plugins are available.
107+
// Here you can do any higher level native things you might need.
108+
statusBar.styleDefault();
109+
splashScreen.hide();
110+
this.checkCodePush();
111+
});
112+
}
113+
114+
checkCodePush() {
115+
116+
this.codePush.sync({
117+
updateDialog: {
118+
appendReleaseDescription: true,
119+
descriptionPrefix: "\n\nChange log:\n"
120+
},
121+
installMode: InstallMode.IMMEDIATE
122+
}).subscribe(
123+
(data) => {
124+
console.log('CODE PUSH SUCCESSFUL: ' + data);
125+
126+
},
127+
(err) => {
128+
console.log('CODE PUSH ERROR: ' + err);
129+
130+
}
131+
);
132+
}
133+
134+
}
135+
```
136+
137+
## Release the update
138+
139+
Modify anything in your app and...
140+
141+
`ionic cordova prepare ios`
142+
143+
`code-push release codepush-ionic-test-ios ./platforms/ios/www/ 0.0.1 --description "Your awesome change description"`
144+
145+
`ionic cordova prepare android`
146+
147+
`code-push release codepush-ionic-test-android ./platforms/android/assets/www/ 0.0.1 --description "Your awesome change description"`
148+
149+
> **Note**: the update will only be released for those devices matching the 0.0.1 version of your app.

config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version='1.0' encoding='utf-8'?>
2-
<widget id="io.ionic.starter" version="0.0.2" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
2+
<widget id="io.ionic.starter" version="0.0.3" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
33
<name>MyApp</name>
44
<description>An awesome Ionic/Cordova app.</description>
55
<author email="hi@ionicframework" href="http://ionicframework.com/">Ionic Framework Team</author>

src/pages/home/home.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,10 @@
1212
If you get lost, the <a href="http://ionicframework.com/docs/v2">docs</a> will be your guide.
1313
</p>
1414

15+
<p>Hey!</p>
16+
<p>Heyo!!</p>
17+
<p>Heyoooo!!!</p>
18+
<p>:D</p>
19+
<p>Wooow!</p>
20+
1521
</ion-content>

0 commit comments

Comments
 (0)