Android Code Snippet FCM messages/notifications: Use Phonewakestate to throw notifications without delay

I mentioned that my fcm messages arrive without delay (data messages), but throwing a notification (even with high priority) doesn't work all the time when the phone sleeps.

Setting the phonewakestate before throwing the notification and releasing it after seems to work:

    Dim n As NB6
    MyIcon = LoadBitmapResize(File.DirAssets, "Someicon.JPG", 24dip, 24dip, False)
    n.Initialize("default", Application.LabelName, "HIGH").AutoCancel(True).SmallIcon(MyIcon)
    n.Build("FCM", "Message sent: " & MyData.get("time") & ", Notification created at " & DateTime.Time(DateTime.Now), "tag1", Main).Notify(4)

Phone Lib is needed pws is defined as phonewakestate in globals in the fcm service (code above is in the service, too)


Active Member
Licensed User
Longtime User
is this a question? or only a advertisement?