@nextgencodecompany/ng-code-push
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Setup

1. Create app on Appcenter

Select iOS & Cordova

2. Copy staging & production deployment keys

Put them into your project config.ts

3. Add APP_SECRET & CodePushDeploymentKey into config.xml

<platform name="ios">
    <preference name="APP_SECRET" value="XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX" />
    <preference name="CodePushDeploymentKey" value="xxxxxxxxxxxxxxxxxxxxxxxx" />
</platform>

<platform name="android">
    <preference name="APP_SECRET" value="XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX" />
    <preference name="CodePushDeploymentKey" value="xxxxxxxxxxxxxxxxxxxxxxxx" />
</platform>

⚠️ Make sure to remove and add platform again

** Cordova will not like it if you do not have CodePushDeploymentKey in config.xml even though this service will be overwriting it

4. Import NGCodePushService as a provider in app.module.ts

...app.module.ts...

import { NGCodePushService } from '@nextgencodecompany/ng-code-push';

...

providers:[
    NGCodePushService
]

5. Inject NGCodePushService into app.component.ts

...app.component.ts...


import { NGCodePushService, NGCodePushConfig } from '@nextgencodecompany/ng-code-push';
import { Config } from '../wherever/project/config/is';

...

constructor( public ngCodePush: NGCodePushService ) {
    // set config for ng-code-push
    const code_push_config: NGCodePushConfig = {
        project_name: Config.project_name,
        on: (Config.dev_mode ? false : Config.codePush.on),
        version: Config.version,
        ignoreFailedUpdates: Config.codePush.ignoreFailedUpdates,
        deploymentKey: Config.codePush.deploymentKey,
        displayUpdatePrompts: Config.codePush.displayUpdatePrompts,
        stagingDeploymentKey: Config.codePush.stagingDeploymentKey
    };
    this.ngCodePush.setConfig(code_push_config);
}

Usage Examples

<ion-item
    detail="true"
    *ngIf="mc.isApp"
    (click)="ngCodePush.checkForUpdate()"
    tappable
>
    <ion-label>
        <ion-text color="dark"> Check for Updates </ion-text>
    </ion-label>
    <ion-spinner
        slot="end"
        *ngIf="ngCodePush.loading"
        name="crescent"
    ></ion-spinner>
</ion-item>
<ng-container *ngIf="mc.loggedInUser?.admin && mc.isApp">
    <ion-list-header>Admin Only</ion-list-header>
    <ion-item lines="none">
        <ion-label>
            <ion-text color="dark"> Show Admin Alerts </ion-text>
        </ion-label>
        <ion-toggle
            [(ngModel)]="ngCodePush.showAdminAlerts"
            (ionChange)="ngCodePush.setCodePushToasts($event.detail.checked)"
        ></ion-toggle>
    </ion-item>

    <ion-item lines="none">
        <ion-label>
            <ion-text color="dark"> Beta Channel </ion-text>
        </ion-label>
        <ion-toggle
            [(ngModel)]="ngCodePush.useBetaChannel"
            (ionChange)="ngCodePush.setBetaChannel($event.detail.checked)"
        ></ion-toggle>
    </ion-item>
</ng-container>

Publishing Scripts (For NEXTGEN)

npm run deploy

This is a full Ionic project directory that only exports and publishes the ng-code-push service.

You can test by running the typical ionic commands.

Please test before publishing.

Readme

Keywords

none

Package Sidebar

Install

npm i @nextgencodecompany/ng-code-push

Weekly Downloads

11

Version

1.0.4

License

none

Unpacked Size

257 kB

Total Files

27

Last publish

Collaborators

  • devion-nextgen
  • tylerholden