Skip to content

WordPress Plugin FCM(Firebase Cloud Messaging) for Android

Notifications You must be signed in to change notification settings

dream-space/wp-fcm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wp-fcm

WordPress Plugin FCM(Firebase Cloud Messaging) for Android

endpoint plugin

{
    "regid": "APA91bHScXXXXXXXX",
    "serial": "Android device serial number D511E1ZR611XXXXX",
    "device_name": "Brand Name (samsung SM-XX, Sony D-XXX, etc)",
    "os_version": "5.0 or 4.1 etc"
}
  • RESPONS :
{
  "status": "success or failed",
  "message": "Message Content"
}

implement fcm

this article may help you :

notification body

  • JSON
{
  "title": "Title Text",
  "content": "Content Text",
  "post_id": post_id in number (optional)
}
  • Android
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    FcmNotif fcmNotif = new FcmNotif();
    if (remoteMessage.getData().size() > 0) {
        Map<String, String> data = remoteMessage.getData();
        fcmNotif.post_id = data.get("post_id") == null ? -1 : Integer.parseInt(data.get("post_id"));
        fcmNotif.title = data.get("title");
        fcmNotif.content = data.get("content");
        fcmNotif.image = data.get("image");
    } else if (remoteMessage.getNotification() != null) {
        RemoteMessage.Notification rn = remoteMessage.getNotification();
        fcmNotif.title = rn.getTitle();
        fcmNotif.content = rn.getBody();
    }
    // Your action display notification here
}
  • Subscribe topic
FirebaseMessaging.getInstance().subscribeToTopic("ALL-DEVICE").addOnCompleteListener(new OnCompleteListener<Void>() {
    @Override
    public void onComplete(@NonNull Task<Void> task) {
        sharedPref.setSubscibeNotif(task.isSuccessful());
    }
});

purchase project implementation

https://codecanyon.net/item/koran-wordpress-app-with-push-notification-20/17470988

About

WordPress Plugin FCM(Firebase Cloud Messaging) for Android

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages