අද මම කියන්න යන්නේ මම ලඟකදී භාවිතා කරන ලද තවත් Xamarin Plugin එකක් ගැනයි.මේ Plugin එක ඇත්තටම හදාලා තියෙන්නේ Firebase Push Notification ඔයාගේ Xamarin app එකට එකතු කිරීම පහසු කිරීමට කිව්වොත් මම නිවැරදියි. මොකද Xamarin.iOS , Xamarin.Android වලදී වැඩ ගොඩක් තියන නිසා එක එක platform වලට වෙනමම Push Notification සේවාවන් යෙදීම ඉතාම අපහසු කාරනාවක් කියලයි මම හිතන්නේ.
ඉතින් අද අපි පාවිච්චි කරන මේ plugin එකේ නම තමා FirebasePushNotificationPlugin කියලා කියන්නේ. මේ Plugin එකට එහෙමත් නැත්නම් Nuget එකට පහත සඳහන් සියලුදේවල් කරන්න පුලුවන් කම තියනවා.
- Receive Firebase push notifications
- Subscribing/Unsubscribing to topics
- Support for push notification category actions
- Customize push notification
මෙහිදී භාවිතාවන Events
මෙම පලගින් එක භාවිතයෙන් ඔබට පහත සඳන් Events , Android, iOSවලට ලබාගන්න පුලුවන් කම තියනවා.
OnTokenRefresh – Provides feedback when token is updated.
CrossFirebasePushNotification.Current.OnTokenRefresh += (s,p) =>
{
System.Diagnostics.Debug.WriteLine($"TOKEN : {p.Token}");
};
OnNotificationReceived – Provides feedback when notification is received.
CrossFirebasePushNotification.Current.OnNotificationReceived += (s,p) =>
{
System.Diagnostics.Debug.WriteLine("Received");
};
OnNotificationOpened– Provides feedback when notification is opened.
CrossFirebasePushNotification.Current.OnNotificationOpened += (s,p) =>
{
System.Diagnostics.Debug.WriteLine("Opened");
foreach(var data in p.Data)
{
System.Diagnostics.Debug.WriteLine($"{data.Key} : {data.Value}");
}
if(!string.IsNullOrEmpty(p.Identifier))
{
System.Diagnostics.Debug.WriteLine($"ActionId: {p.Identifier}");
}
};
Cross platform topic subscription
මෙමගින් ඔබට එක් එක් Topics සඳහා වෙන වෙනම අදාල Filters සඳහා Subscribe කිරීමට හා Filter කිරීමට හැකියාව ලැබෙනව. පහත events භාවිතයෙන් අදාල topics සඳහා පමණක් subscribe කිරීමෙන් එම topics filter වී ලැබෙනු ඇති.
//Subscribing to single topic
CrossFirebasePushNotification.Current.Subscribe("general");
//Subscribing to multiple topics
CrossFirebasePushNotification.Current.Subscribe(new string[]{"baseball","football"});
//Unsubscribing to single topic
CrossFirebasePushNotification.Current.Unsubscribe("general");
//Unsubscribing from multiple topics
CrossFirebasePushNotification.Current.Unsubscribe(new string[]{"food","music"});
//Unsubscribing from all topics
CrossFirebasePushNotification.Current.UnsubscribeAll();
මෙම සම්පූර්ණ Plugin එකෙහි Open Source Source Code එක පහතින් ගන්න.
https://github.com/CrossGeeks/FirebasePushNotificationPlugin
පහත් වීඩියෝ එකෙන් සම්පූර්ණ භාවිතයම මුල සිට බලාගන්න පුලුවන්