Background notifications delivery timestamp

Hello everyone,

I’ve been developing with Corona for a few months now, but I really need to understand if something is doable or not… it’s sort of a game changer otherwise. I’m working on an Android-only app at the moment.

First of all I’m ok with LUA not being called when my app receives a notification and it’s in background.

I can always read the payload when the user clicks on the badge and all is good, but I really need the delivery time of the notification in the event and I can’t seem to find a way to access it. It would be trivial in pure Java to timestamp the notification in the background service, but seems like I would need an Enterprise license just to do that… 

Anyone can help here? I’m stuck and really considering alternatives if this can’t be done at all…

Thanks,

Ivan

Hi Ivan,

Can you share a bit of code on what you’re doing to dispatch the notification currently? Please surround the code with “lua” tags for clarity in the forum thread:

[lua] -- code [/lua]

Thanks,

Brent

Hi Brent,

the code is just a notification listener and works just fine. I was asking if there was a way somehow to access the delivery timestamp (as in the ms timestamp of when the background service received the notification in case the app is hibernated/closed). I need it for a simple chat system I’m implementing in the game I’m developing.

I need to show the users at what time the message was received (not sent from the server).

Also, the server sometimes sends a notification prompting the user to tap it within a specified amount of time… but if I don’t know when it’s received I really can’t make it work.

Any help is really super appreciated at the moment, 'cause I’m totally lost in code :slight_smile:

Thanks a lot,

Ivan

Which push notification service are you using?

Standard GCM in conjunction with my own java server for packing and sending the notifications.

Hi Brent,

just a little ping to know if I have to give up or it’s something doable (maybe a little update to the platform? :P).

Thanks a lot,

Ivan

Our engineers suggest that you try and package a timestamp in your custom table. You can get the UTC unix time and save it as a string (in case the number exceeds some max limits). You can look at our sample app:  SampleCode/System/GooglePushNotifications to see an example of how to work with a custom table.

Rob

Hi Rob,

the fact is that I don’t need the time from the server, I need the time of when the notification is received. I can’t rely on a server timestamp for many reasons (out of network, phone turned off, airplane mode, etc…). In java I’d simply timestamp the message in the background receiver and push it in a queue for later handling, but in Corona I don’t get anything when my app is in background so I can’t interact with the raw notification. Consider for example a chat system: how can I tell the server when a message has been delivered if I only have access to the data when the user clicks on the notification? Also, as I said in a previous message, our server randomly sends a notification to a client and the user has X seconds to click it to get some reward… but I can’t know when the notification has been received, so I can start counting only after the user clicks on it and wakes the app. As this is quite crucial for our game logic I need to know if, even in the near future, the notifications could be timestamped upon being received or not.

Thanks a lot for the support,

Ivan

We don’t support time-stamping push notifications when it’s received in the background and there really isn’t a practical way to do it in Corona Enterprise either.

Rob

Hi Rob,

I know I’m asking something unusual, but would it be possible to just add it in the background receiver before sending the table to lua? I mean, I know I’m asking for a platform modification, but it could come really useful for other users too.

If this is not possible then I’ll have to fallback to a more complex but standard development pipeline with android studio and pure java… but I really wouldn’t want to go that route unless it’s really necessary…

Thanks a lot,

Ivan

Hi Ivan,

Can you share a bit of code on what you’re doing to dispatch the notification currently? Please surround the code with “lua” tags for clarity in the forum thread:

[lua] -- code [/lua]

Thanks,

Brent

Hi Brent,

the code is just a notification listener and works just fine. I was asking if there was a way somehow to access the delivery timestamp (as in the ms timestamp of when the background service received the notification in case the app is hibernated/closed). I need it for a simple chat system I’m implementing in the game I’m developing.

I need to show the users at what time the message was received (not sent from the server).

Also, the server sometimes sends a notification prompting the user to tap it within a specified amount of time… but if I don’t know when it’s received I really can’t make it work.

Any help is really super appreciated at the moment, 'cause I’m totally lost in code :slight_smile:

Thanks a lot,

Ivan

Which push notification service are you using?

Standard GCM in conjunction with my own java server for packing and sending the notifications.

Hi Brent,

just a little ping to know if I have to give up or it’s something doable (maybe a little update to the platform? :P).

Thanks a lot,

Ivan

Our engineers suggest that you try and package a timestamp in your custom table. You can get the UTC unix time and save it as a string (in case the number exceeds some max limits). You can look at our sample app:  SampleCode/System/GooglePushNotifications to see an example of how to work with a custom table.

Rob

Hi Rob,

the fact is that I don’t need the time from the server, I need the time of when the notification is received. I can’t rely on a server timestamp for many reasons (out of network, phone turned off, airplane mode, etc…). In java I’d simply timestamp the message in the background receiver and push it in a queue for later handling, but in Corona I don’t get anything when my app is in background so I can’t interact with the raw notification. Consider for example a chat system: how can I tell the server when a message has been delivered if I only have access to the data when the user clicks on the notification? Also, as I said in a previous message, our server randomly sends a notification to a client and the user has X seconds to click it to get some reward… but I can’t know when the notification has been received, so I can start counting only after the user clicks on it and wakes the app. As this is quite crucial for our game logic I need to know if, even in the near future, the notifications could be timestamped upon being received or not.

Thanks a lot for the support,

Ivan

We don’t support time-stamping push notifications when it’s received in the background and there really isn’t a practical way to do it in Corona Enterprise either.

Rob

Hi Rob,

I know I’m asking something unusual, but would it be possible to just add it in the background receiver before sending the table to lua? I mean, I know I’m asking for a platform modification, but it could come really useful for other users too.

If this is not possible then I’ll have to fallback to a more complex but standard development pipeline with android studio and pure java… but I really wouldn’t want to go that route unless it’s really necessary…

Thanks a lot,

Ivan