@iSkyDive wrote:
Hello everyone !
I started Ionic v2 a week ago and I now need to use the clipboard plugin (https://ionicframework.com/docs/native/clipboard/) and the Local notifications plugin (https://ionicframework.com/docs/native/local-notifications/).
First at all, I installed them by running the right commands as shown in the tutorial, then I imported them to my app.module.ts and referred them in the providers list.
After this, I imported them as well in my home.ts or in my notif-modal.ts and added them to the constructor parameters.
But then, when I want to use them, it doesn't work ...
I noticed that I don't have the plugin line for local notifications in config.xml, but I do have the clipboard one :
<plugin name="com.danielsogl.cordova.clipboard" spec="~1.0.2" />Here is my codes, do someone have any idea ?
Here is app.module.ts :
... import { Clipboard } from '@ionic-native/clipboard'; import { LocalNotifications } from '@ionic-native/local-notifications'; @NgModule({ declarations: [ ... ], imports: [ ... ], bootstrap: [IonicApp], entryComponents: [ ... ], providers: [ ... LocalNotifications, Clipboard ] })Then my notif-modal.ts (to set the notifications) :
... import { LocalNotifications } from '@ionic-native/local-notifications'; /** * Generated class for the NotifModalPage page. * * See http://ionicframework.com/docs/components/#navigation for more info * on Ionic pages and navigation. */ @IonicPage() @Component({ selector: 'page-notif-modal', templateUrl: 'notif-modal.html', }) export class NotifModalPage { constructor(public navCtrl: NavController, public navParams: NavParams, public viewCtrl: ViewController, public platform: Platform, public localNotifications: LocalNotifications) { platform.ready().then(() => { platform.registerBackButtonAction(() => { this.viewCtrl.dismiss(); }); }); } closeModal() { let firstNotificationTime = new Date(); firstNotificationTime.setMinutes(firstNotificationTime.getMinutes() + 1); this.localNotifications.schedule({ id: 1, title: 'Hey!', text: 'You just got notified :)', at: firstNotificationTime }); this.viewCtrl.dismiss(); } }As you can see, I just try to set a SIMPLE notification, with a fixed ID, fixed title, fixed text, and the actual data plus one minute ...
Next, for the clipboard plugin, here is the interesting part of home.ts :
... import { Clipboard } from '@ionic-native/clipboard'; @Component({ selector: 'page-home', templateUrl: 'home.html' }) export class HomePage { constructor(public navCtrl: NavController, public modalCtrl: ModalController, private keyboard: Keyboard, public alertCtrl: AlertController, public storage: Storage, private clipboard: Clipboard) { } export() { this.clipboard.copy("hello"); let alert = this.alertCtrl.create({ title: 'Copied !', subTitle: 'Copy done !', buttons: ['Ok'] }); alert.present(); }); } }The alert pop up, but still, if I try to paste somewhere I don't have anything in my clipboard...
Thanks for those who will be able to help, that's the last step of my application
Posts: 1
Participants: 1
