My Blog

Menu

Push Notification

Posted: November 24, 2021. | By: Admin

Push Notification (https://ionicframework.com/docs/native/push/)

1)Install plugin 
    a)ionic cordova plugin add phonegap-plugin-push --variable SENDER_ID=XXXXXXXXX(SENDER_ID from FireBase console)
    b)npm install --save @ionic-native/push
2)Intialize Push
    a)const options: PushOptions = {android: {senderID: 'XXXXXXXXX'},ios: {alert: 'true',badge: true,sound: 'false'},windows: {}};
    b)const pushObject: PushObject = this.push.init(options);
3)Show push notification
    pushObject.on('notification').subscribe((notification: any) => console.log('Received a notification', notification));
4)Get registration Id.
    pushObject.on('registration').subscribe((registration: any) => console.log('Device registered', registration));
5)Send Push Notification.
    a)Data
        json={"notification": {"title": "Notification title","body": "Notification body","sound": "default","click_action": "FCM_PLUGIN_ACTIVITY",
        "icon": "fcm_push_icon"},"data": {"hello": "This is a Firebase Cloud Message!",},"to": registration.registrationId}
    b)post values    
        var params = json;
        var headers = new Headers({'Content-Type': 'application/json','Authorization': 'key=SERVERKEY'}); 
        this.http.post('https://fcm.googleapis.com/fcm/send',params, {headers: headers}).map(res => res.json(),Error=>alert('error'))
 

About

Aapthi Technologies,Hyderabad offers a complete range of web solutions including web designing, developing, web hosting, Internet marketing and many more. With our electrifying presence, we have swirled the scenario of web solutions. We consistently invigorate our skill-set and tech-expertise and work with a high-level of integrity. Our keen-eye on emerging trends of online business as well as technical spheres has empowered us to render the most innovative solutions. Persistent development is the key drive of Aapthi Technologies, be it in terms of infrastructure, skill-set or technology. Team Aapthi Technologies, is fully committed to render back hundred percent value for the money paid by client.

Social Links

Our Bunker

Plot No -596, Near Reliance Fresh,
Vivekananda nagar colony, Kukatpally,
Hyderabad - 500072, India.