Zum Inhalt

Installation

Vorbereitung

Contentfly CMS

CORS-Einstellungen

Um das Contentfly SDK in Ionic nutzen zu können, müssen im Contentfy CMS Backend die CORS-Einstellungen konfiguriert werden.

custom/config.php

1
2
3
4
<?php
$configDefault->APP_ALLOW_ORIGIN            = '*';
$configDefault->APP_ALLOW_HEADERS           = 'content-type, x-xsrf-token, appcms-token, authorization';
$configDefault->APP_ALLOW_CREDENTIALS       = true;

Benutzer und Gruppe

  • Es muss ein Benutzer angelegt und sinnvollerweise einer Gruppe zugeordnet sein
  • Für die Benutzergruppe müssen folgende Einstellungen gesetzt sein:
    • Zugriff auf api/query erlauben = JA
    • Token-Timeout = 0 (empfohlen)
    • Zugriff auf die gewünschten Entitäten setzen

Ionic installieren

Zu Beginn muss Ionic und Cordova auf dem Entwicklungsrechner installiert sein:

1
npm install -g ionic cordova

App initialisieren

Die Ionic-App muss in der Version 3 initalisiert werden, das erreichen Sie mit dem aktuellen Ionic CLI über die Angabe des Typs ionic-angular:

1
ionic start APPNAME --type=ionic-angular

Ionic 3 vs Ionic 4

Das Contentfly SDK unterstützt derzeit lediglich Ionic 3, die Version 4 wird noch nicht unterstützt.

Plattformen hinzufügen

Plattformen - je nach Bedarf - hinzufügen:

1
2
ionic cordova platform add ios
ionic cordova platform add android

Contentfly SDK installieren

NPM-Paketmanager

Das Contentfly Ionic SDK ist über den Paketmanager npm als Modul installierbar.

npm install --save contentfly-ionic

Abhängigkeiten installieren

Folgende Module müssen zusätzlich installiert werden:

SQLite

1
2
ionic cordova plugin add cordova-sqlite-storage
npm install --save @ionic-native/sqlite@4

File

1
2
ionic cordova plugin add cordova-plugin-file
npm install --save @ionic-native/file@4

Ionic 3 vs Ionic 4

Alle Ionic Native Plugins müssen für Ionic 3 in der Version „@4“installiert werden. Ohne diese Angabe werden inzwischen die Plugins für die 4er-Version standardmäßig installiert.

Contentfly SDK im App-Hauptmodul hinzufügen

Um das Contentfly Ionic SDK innerhalb des eigenen Projektes nutzen zu können, muss es in der app.module.ts bekannt gemacht werden. Für zusätzliche Konfigurationseinstellungen empfehlen wir das Anlegen einer separaten Konfigurationsdatei, z.B. app/config.ts:

app/app.module.ts

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule } from 'ionic-angular';
import { MyApp } from './app.component';
import {ContentflyModule, ContentflySdk} from "contentfly-ionic";
import {CONTENTFLY_URL} from "./config";

@NgModule({
  declarations: [
    MyApp
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp, {}),
    ContentflyModule.forRoot({
      baseUrl: CONTENTFLY_URL
    })
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp
  ],
  providers: [
    ContentflySdk,
    ...
  ]
})
export class AppModule {}

app/config.ts

1
export const CONTENTFLY_URL : string = 'https://app.domain.de;

Hinweise

Folgende Abhängigkeiten werden unter anderem über das Modul mitinstalliert und unterstützt:

  • Angular: 5.2.9 bis < 6.0.0
  • Angular HttpClient: 5.2.9 bis < 6.0.0
  • Ionic Native 4.11.0 bis < 5.0.0
  • Ionic Storage 2.1.3 bis < 3.0.0
  • ionic-angular: 3.9.2 bis < 4.0.0
  • cordova-plugin-file: 6.0.1 bis < 7.0.0
  • cordova-sqlite-storage: 2.3.0 bis < 3.0.0