Closed mravizza closed 6 years ago
I'm fairly sure that issue has to do with how the ionic-push module has been exported, and with how you use TS on your project (which might again fall on ionic's lap), seeing as you're unable to use both the value and the type sides of the type definitions.
I've seen that issue come up on DefinitelyTyped before, and it was not completely solvable afaik.
You might get a better result at asking the guys over at the ionic forums, for we only export a raw source code and a raw type definition file, separated from each other (which means it's probably not reproducible without ionic).
This thread has been automatically locked.
Expected Behaviour
No error on running the following command: ionic serve -c –lab
Actual Behaviour
Starting app-scripts server: --address 0.0.0.0 --port 8100 --livereload-port 35729 --dev-logger-port 53703 --consolelogs --nobrowser --platform –lab - Ctrl+C to cancel [18:46:07] watch started ... [18:46:07] build dev started ... [18:46:07] clean started ... [18:46:07] clean finished in 13 ms [18:46:07] copy started ... [18:46:08] deeplinks started ... [18:46:08] deeplinks finished in 151 ms [18:46:08] transpile started ... [18:46:15] typescript: C:/Users/mravi/ionic/lending-shopping-basket-v2/src/app/app.module.ts, line: 61 'PushOptions' only refers to a type, but is being used as a value here.
[18:46:15] dev server running: http://localhost:8100/
[OK] Development server running! Local: http://localhost:8100 External: http://172.23.49.161:8100, http://10.0.75.1:8100, http://192.168.1.115:8100 DevApp: lending-shopping-basket-v2@8100 on mravizza-Notebook
[18:46:15] copy finished in 7.60 s [18:46:15] watch ready in 8.02 s
Reproduce Scenario (including but not limited to)
` import { Component } from '@angular/core'; import { Platform } from 'ionic-angular'; import { StatusBar } from '@ionic-native/status-bar'; import { SplashScreen } from '@ionic-native/splash-screen'; import { Push, PushObject, PushOptions } from '@ionic-native/push';
import { TabsPage } from '../pages/tabs/tabs';
@Component({ templateUrl: 'app.html' }) export class MyApp { rootPage:any = TabsPage;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, push: Push) { platform.ready().then(() => { // Okay, so the platform is ready and our plugins are available. // Here you can do any higher level native things you might need. statusBar.styleDefault(); splashScreen.hide(); });
push.hasPermission() .then((res: any) => {
// to initialize push notifications
var options: PushOptions = { android: { senderID: '235918690924' }, ios: { alert: 'true', badge: true, sound: 'false' }, windows: {}, browser: {} };
var pushObject: PushObject = push.init(options);
pushObject.on('registration').subscribe((data: any) => { console.log('Device token/handle is: ' + data.registrationId); alert('Device token/handle is: ' + data.registrationId); });
// https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/API.md#pushnotificationinitoptions pushObject.on('notification').subscribe((data: any) => { console.log('Push Received: ' + data.additionalData); console.log(data.message); console.log(data.title); console.log(data.count); console.log(data.sound); console.log(data.image); console.log(data.additionalData); alert('New Notification' + data.additionalData); });
pushObject.on('error').subscribe(error => { console.log("ERROR is: " + error); });
} } `
Steps to Reproduce
Run: ionic serve -c –lab
Platform and Version (eg. Android 5.0 or iOS 9.2.1)
(Android) What device vendor (e.g. Samsung, HTC, Sony...)
(doesn't matter because test on PC)
Cordova CLI version and cordova platform version
Installed platforms: android 7.1.0 browser 5.0.3 ios 4.5.4 Available platforms: osx ~4.0.1 windows ~5.0.0 www ^3.12.0
Plugin version
cordova-plugin-advanced-http 1.11.1 "Advanced HTTP plugin" cordova-plugin-compat 1.2.0 "Compat" cordova-plugin-device 2.0.2 "Device" cordova-plugin-file 6.0.1 "File" cordova-plugin-firebase 1.0.5 "Google Firebase Plugin" cordova-plugin-ionic-keyboard 2.0.5 "cordova-plugin-ionic-keyboard" cordova-plugin-ionic-webview 1.1.19 "cordova-plugin-ionic-webview" cordova-plugin-splashscreen 5.0.2 "Splashscreen" cordova-plugin-statusbar 2.4.2 "StatusBar" cordova-plugin-whitelist 1.3.3 "Whitelist" cordova-support-google-services 1.1.0 "cordova-support-google-services" phonegap-plugin-barcodescanner 7.1.2 "BarcodeScanner" phonegap-plugin-multidex 1.0.0 "Multidex" phonegap-plugin-push 2.2.3 "PushPlugin"