Search This Blog

22 July 2019

Ionic 3 using Push Notification

Ionic 3 using Push Notification With Firebase

Firebase:

firebase  is google platform its used mobile and web application , google provide  some features  like as  in app messaging , firebase push notification , google cloud messaging , remote config , firebase cloud function , firebase database and firebase firestore if you use firebase in your app is high_quality application, relabel and more fast

Steps:

Login Into Your Gmail Account 

search Firebase to Google --> Open Console  -> create New Project ---> etc...Open Project  (android,ios,web) --> select oneI choose AndroidRegister App  --> com.yournameapp.app  ( your Config.xml file id like same as       com.yournameapp.app) 

Nick Name --> Optional if you want to give or not necessary Register AppDownload Googleservice.json File Copy this File Under Root Directory of Your Project  

Add FireBase SDK to Your Build.gradle file platform/android/...etc

Install this Plugin ana open the cmd prompt change directory to switch your project directory and run this command 

$ionic cordova plugin add cordova-plugin-fcm-with-dependency-updated

$npm install @ionic-native/fcm@4 --save

then open your project under src/ app

select app.modules.ts open this file -->add the modeuls 

var firebaseConfig = {  

apiKey: "fgfhg", 

 authDomain: "test-9c526.firebaseapp.com", 

 databaseURL: "https://test-9c526.firebaseio.com", 

 projectId: "test-9c826",  

storageBucket: "test-9c526.appspot.com",

  messagingSenderId: "54354353545", 

 appId: "1:34844348772050:web:d775454f03f53fe10cee0tgg86a8b"

};

@NgModule({ 

 declarations: [   MyApp,    HomePage  ], 

 imports: [    BrowserModule,    AngularFireAuthModule,    AngularFireDatabaseModule,    AngularFireModule.initializeApp(firebaseConfig),    IonicModule.forRoot(MyApp)  ],  bootstrap: [IonicApp],  entryComponents: [    MyApp,    HomePage  ], 

 providers: [    StatusBar,    AdMobFree,    Geolocation,    Diagnostic,    NativeGeocoder,    SocialSharing,    SplashScreen,    CallNumber,    {provide: ErrorHandler, useClass: IonicErrorHandler}  ]})

constructor(public navCtrl: NavController,public afd: AngularFireDatabase) {    this.tokensetup().then((token) => { 

     this.storetoken(token);    

})  }  

ionViewDidLoad()  { 

FCMPlugin.onNotification(function(data){    if(data.wasTapped){      // Notification was received on device tray and tapped by the user.    

   }else{      

// Notification was received in foreground. Maybe the user needs to be notified.       }    });

FCMPlugin.onTokenRefresh(function (token){});     } 

tokensetup() {   

 var promise = new Promise(( resolve, reject) => {  

    FCMPlugin.getToken( function (token){   

 resolve (token);      },

 (err) => {     

  reject (err);  });   

 })    return promise;  } 

 storetoken(t) {   

 this.afd.list(this.firestore).push({      uid: " user1 ",     devtoken: t    }).then(() => {   }).catch(() => {      //  alert (' Token not stored ');      }) }

Build Apk  installe it then Verify sdk the  go to google  cloud Messaging tab send message give notification name and title , target the app , sounds are enable or not then finally send or draft

5 comments:

  1. Thanks for sharing the code of Ionic 3 using Push Notification With Firebase.
    PHP Development Company

    ReplyDelete

  2. https://intelicle.com/web-design-nottingham/
    Intelicle offers dynamic and cutting-edge web design and development services that are ideal for any project with bespoke and
    complex requirements. Our team develops mobile apps, web portals and e commerce solutions that are easy to maintain and use.
    Furthermore, our SEO and digital marketing team will help you attract your target audience by establishing your business as a
    unique brand.
    web design services
    web development services
    web design services in UK

    ReplyDelete
  3. WebberHub is the best source to get many types of tutorials related to web design and deveopment. This provide many article related to web design and devolopment, computer programming, SEO, internet and technology. So, webber hub provides many free and pro web templates, wordpress templates and plugins also. as well as, webber hub is a best place to make your next website project. We accept any types of website project. There are many sotisfied client around webber hub.

    ReplyDelete
  4. Great post.Thanks for one marvelous posting! I enjoyed reading it;The information was very useful.
    Web Development Islamabad

    ReplyDelete
  5. The Indian Web Developers is the one-stop solution for all type of sites. Whether it's an e-commerce or an informative website, We have created the website development for each venture.The experienced professionals in Indian Web Developers have the capability of building a robust and bug-free website for you.

    ReplyDelete

Jquery or Javascript Start Exam Time

 <script> function startTimer() {      var date = "<?php echo $date ?>"; // dynamic date      var time = "<?...