Ana içeriğe atla

Ionic Android Push Notification

Ionic push notifications are really easy to implement but if you couldn't find the best tutorial to use push notification yet it can't be easy at the first. Due to this reason I decide to prepare this small tutorial for ionic developers.

Lets start with easy steps.

Android Push Notification

 - Create Firebase account at here https://firebase.google.com/

 - After creating your firebase account click to "GO TO CONSOLE" button from right top corner of page. (you should redirect to https://console.firebase.google.com/ link.)

 - Click to "Create Project" button and enter dummy values to input. Just care about application package name while you fill the input, it should has same name with your project root directory config.xml file widget id value.

 - Then end of the creating new project wizard you should download google-services.json file to your project "projectName/platforms/android/app/" directory.

- click the settings in the top of left nav bar and go to 'Cloud Messaging'  menu.then copy your senderID to use following steps.

- then run the following commands in console


cd projectName
ionic cordova plugin add phonegap-plugin-push --variable SENDER_ID=yoursenderId

npm install --save @ionic-native/push


 - Then open component.ts file and add to following codes.

import { Push, PushObject, PushOptions } from '@ionic-native/push';

constructor(private push: Push) {

this.pushInit();

}

pushInit(){


const options: PushOptions = { android: {
senderID:'put your senderId here'
}, ios: { alert: 'true', badge: true, sound: 'false' } }; const pushObject: PushObject = this.push.init(options); pushObject.on('notification').subscribe((notification: any) => console.log('Received a notification', notification)); pushObject.on('registration').subscribe((registration: any) => console.log('Device registered', registration));
pushObject.on('error').subscribe(error => console.error('Error with Push plugin', error));


}


 - now when you start your application, you can get push message and regsiteredDeviceId values.

 - after that you can use 'Cloud Messaging' link from left nav menu and send push message to all users or deviceId spesific users.








Bu blogdaki popüler yayınlar

Cannot resolve the collation conflict between "Turkish_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.

iki ayrı veri tabanı içindeki tablolar ile işlem yapılmak istendiğinde eğer dil sorunu çıkıyor ise sorgumuzun sonuna 'COLLATE TURKISH_CI_AS' sözcüğünü ekleyerek sorunu çözebiliriz.Örnek : SELECT * FROM veritabani1.dbo.URUN u1 INNER JOIN veritabani2.dbo.URUNLER u2 ON u1.kod = u2.kod COLLATE TURKISH_CI_AS umarım faydalı olmuştur.

IEnumerable ile List Arasındaki Farklar

Sık kullandığımız iki tip olan IEnumerable ve List tipleri ile ilgili sürekli kullanılmasına rağmen farkının çok bilinmediğini düşünerek bu konuda kısa bir yazı yazmak istedim. Bakalım aralarında farklar nelermiş. IEnumerable bir interface iken, List yine IEnumerable sınıftan türeyen somut ( concrete) bir sınıftır. Arasındaki Farklar :  IEnumerable  - List e göre iteration çok daha hızlıdır. Performans için kullanılabilir.  - Read Only bir tip olduğu için Add, Remove gibi işlemler yapılamaz, IEnumerable ile sadece iteration, sort, filter gibi işlemler yapılabilir.  - Soyut bir class olduğu için istenen tipe somutlaştırılabilir.  - yield tipi ile birlikte kullanılabilir.(Promise veri döndürme,state-machine liste kullanımı)  - Linq sorguları veri tabanı sorgularınızın cevaplarınızı IEnumerable olarak döndürür, bu size siz ilgili IEnumerable list i iterate edene kadar ilgili sorguyu çalıştırmama performansı verir, böylece ilgili listeyi kullanmaya ihtiyacınız olmadığı bir durumda yada k

Logo (LOJECTS.exe ve LOBJECTS.dll) Register İşlemleri

LOBJECTS.dll register işlemi : başlat-> çalıştır -> cmd yazıp konsole ekranına geçiyoruz REGİSTER İÇİN : regsvr32 logoDosyaYolu\LOBJECTS.dll yazıyoruz ve dll imizi register ediyoruz UNREGISTER İÇİN : regsvr32 -u logoDosyaYolu\LOBJECTS.dll ile de unregister edebiliriz. LOBJECTS.exe register işlemi : başlat-> çalıştır -> cmd yazıp konsole ekranına geçiyoruz REGİSTER İÇİN : logoDosyaYolu\LOBJECTS.exe -REGSERVER yazıyoruz ve LOBJECTS.exe mizi register ediyoruz. UNREGISTER İÇİN : logoDosyaYolu\LOBJECTS.exe -UNREGSERVER yazıyoruz ve LOBJECTS.exe mizi unregister ediyoruz. Umarım yararlı olmuştur.