We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi,
I am using ionic 2.
my app is received local notifications.
i used this plugin
Cordova local notifications and also refer this link
https://ionicframework.com/docs/v2/native/local-notifications/
Here is my component.
import { Component } from '@angular/core'; import { NavController, NavParams ,Platform} from 'ionic-angular'; import { LocalNotifications} from 'ionic-native'; import { FirebaseAuth, AuthProviders, AuthMethods} from 'angularfire2'; import { Authservice } from '../../providers/authservice'; import { FormBuilder } from '@angular/forms'; import { AngularFire } from 'angularfire2'; declare var Media:any; /* Generated class for the Dashboard page. See http://ionicframework.com/docs/v2/components/#navigation for more info on Ionic pages and navigation. */ @Component({ selector: 'page-dashboard', templateUrl: 'dashboard.html' }) export class DashboardPage { EMERGENCY=[]; ApartID; USERID; audio; audioplaying; constructor(public af:AngularFire,public fb:FormBuilder,public platform: Platform,public authservice:Authservice,public navCtrl: NavController, public navParams: NavParams, public auth: FirebaseAuth) { var aid = localStorage.getItem('apartid'); console.log(aid); if(aid !== undefined) { this.af.database.list('/alarm', { query: { orderByChild: 'APART_ID', equalTo: aid } }).subscribe(a => { console.log(a); }) } this.platform.ready().then(() => { var url='https://firebasestorage.googleapis.com/v0/b/apartments-ea9e5.appspot.com/o/Loud-Ringtone-11-Emergency-Alert.mp3?alt=media&token=7d67b437-e96b-484e-bd97-008106a06dcb'; this.audio = new Media(url, // success callback function () { console.log("playAudio():Audio Success"); }, // error callback function (err) { console.log("playAudio():Audio Error: " + err); }, function(statusCallback){console.log("Status"+statusCallback) this.audioplaying = statusCallback; } ); //Get Current UserID var roleid1=localStorage.getItem('Roleid'); this.authservice.getcurrentuserID().subscribe( data=>{ this.ApartID=data[0].APART_ID; this.USERID=data[0].USER_ID; this.EMERGENCY=[]; if(roleid1 === '2' || roleid1 === '5') { this.authservice.GetEmergencytype(this.ApartID).subscribe(d=>{ var EM=d; this.EMERGENCY=EM.filter(a=>a.FROM.toString() != this.USERID.toString()); console.log("EMERGENCY"); var emergencyval=this.EMERGENCY.filter(d=>d.STATUS == 'ON'); console.log("TYPE"); console.log(emergencyval); if(emergencyval.length != 0) { if(emergencyval[0].STATUS === "ON") { var e=emergencyval[0]; var key=emergencyval[0].$key; this.schedule(e); LocalNotifications.on("click", (notification, state) => { this.audio.stop(); console.log("state"); console.log(state); this.af.database.list('/alarm').update(key,{STATUS:'OFF'}); this.navCtrl.setRoot(AlarmdetailsPage); }); } if(emergencyval[0].STATUS === "OFF") { console.log("Playing"); console.log(this.audioplaying); } } }) } }) }) } ionViewDidLoad() { console.log('ionViewDidLoad DashboardPage'); } //receive notifications schedule(a) { console.log("receive Notification") var val=a; var t:any=a.MSG; var time:any=a.SEND_TIME; LocalNotifications.schedule({ title: "Smart Premises", text: t, at: time, sound:this.playSelectedTrack(), }); } playSelectedTrack():any{ console.log("audio play"); this.audio.play(); } }
My app is currently used or not and received notifications at any time.
I need Only receive notifications on app is runned on backround.
I have no idea.
Kinldy advice me,
Thanks.
The text was updated successfully, but these errors were encountered:
Please update the issue with the template in #1188.
Use that to actually explain what your problem is as its not clear.
Sorry, something went wrong.
Closed as no response from original poster.
No branches or pull requests
Hi,
I am using ionic 2.
my app is received local notifications.
i used this plugin
Cordova local notifications and also refer this link
https://ionicframework.com/docs/v2/native/local-notifications/
Here is my component.
My app is currently used or not and received notifications at any time.
I need Only receive notifications on app is runned on backround.
I have no idea.
Kinldy advice me,
Thanks.
The text was updated successfully, but these errors were encountered: