Notifications and Background Process

Greetings Corona Community

As I read from here:

https://forums.coronalabs.com/topic/36566-run-process-in-background/

we can’t run background process.

However we can send push notifications according to here

https://docs.coronalabs.com/guide/events/appNotification/index.html#usage

And there are some good push notification systems that presented in that topic.

However I am a bit dumb  :rolleyes:  :unsure:  I couldn’t figure out

a- If the app is not working in the background, how can it take push notification? Or how will it come?

b-“The app has to support a registration process and it must support incoming messages.” Could you explain details of this issue? Should the app have a process for users about registering the system by email, name etc? Or something different?

c- I am good about using rss feed systems. I can trigger local notification when the user starts the application. But I want to trigger it with my command. Lets be more clear:

  1. The user installs the application. (11:00)
  2. The user opens the application. (11:30) It checks the rss and store some data.
  3. The user closes the application or close the phone (12:00)
  4. The user opens the phone. (14:00)
  5. Phone checks if there is a new content or not (15:00) No new content, no new notification .  Because the data is still same with no 2.
  6. The admin gives a new content by rss (18:43) 
  7. Phone checks if there is a new content or not (19:00) Phone detects a notification because the rss is different from no 5 or no 1.
  8.  It triggers an local notification. Notification pics come from local files of the app. 
  9. Phone gives an local notification (19:01)
  10. The user notices the notification by sound or by shake (19.01)

Extra - The admin gets a feedback from the app that if the user gets the notification or not (Not very important section)

I tried to write very clear. I am not looking for coding of course but I am trying to figure out that if it is possible with corona or not.

Well I still couldn’t solve it.

Any idea?

based on what you said, it looks like it can be done. The app can get data from your server or from the push-notification sent (4kb of data using event.custom )

https://docs.coronalabs.com/guide/events/appNotification/index.html

@yosu

Greetings

Yes the real solution is push notifications. However I am trying to figure out the system of push notifications and background process. Also because I didn’t understand the general process of them, I am looking a solution without push notification  :)  :ph34r: is it possible?

Hey Ersinerchin,

I will try and help you out, I did have background mode (GPS and queries from Parse) working on iOS before the iOS9 update, and I’m currently working to get it back. I potentially had it spoofed and thus it was patched, but it did work till then.

If I figure it out again, I’ll let you know.

Regards,

Aidan

So in the end, we couldn’t solve it :frowning: we need to use only push notifications…

a- If the app is not working in the background, how can it take push notification? Or how will it come?

b-“The app has to support a registration process and it must support incoming messages.” Could you explain details of this issue? Should the app have a process for users about registering the system by email, name etc? Or something different?

c- I am good about using rss feed systems. I can trigger local notification when the user starts the application. But I want to trigger it with my command. Lets be more clear:

  1. The user installs the application. (11:00)
  2. The user opens the application. (11:30) It checks the rss and store some data.
  3. The user closes the application or close the phone (12:00)
  4. The user opens the phone. (14:00)
  5. Phone checks if there is a new content or not (15:00) No new content, no new notification .  Because the data is still same with no 2.
  6. The admin gives a new content by rss (18:43) 
  7. Phone checks if there is a new content or not (19:00) Phone detects a notification because the rss is different from no 5 or no 1.
  8.  It triggers an local notification. Notification pics come from local files of the app. 
  9. Phone gives an local notification (19:01)
  10. The user notices the notification by sound or by shake (19.01)

Extra - The admin gets a feedback from the app that if the user gets the notification or not (Not very important section)

I tried to write very clear. I am not looking for coding of course but I am trying to figure out that if it is possible with corona or not.

a - Push notifications do not require the app to be running. On iOS the OS handles the notification. On Android, I believe it calls part of your program (which Corona does under the hood) to handle  the notifiacation.

Depending on the state of the app, how the app handles the push varies:

  1. App is not in memory, use interacts with the push:

In this case, the OS starts your app and you will get a launchArgs table set that has the data from the push notification in it.

  1. App is not in memory, push comes in, but the user starts the app from it’s main icon:

The app gets no information from the push notification. No events are generated, no launchArgs is set.

  1. The App is in the foreground running:

The App will get a notification event and your app should handle it as necessary

  1. The App is backgrounded, user interacts with the push:

App is foregrounded and receives a notification event.

  1. The app is backgrounded, user starts the app from it’s icon.

Like above, no push events are generated and there is no way for the app to get info from the push.

B. When your app starts up, you will get a registerDevice event. This will include a really long hex string that identifes your device. Corona will automatically send this data to Apple or Google (if you have things setup correctly) to register the device-app combination with their servers than send push notifications. Then it’s your responsibility to respond to the register event and update your push notification sender (PushWoosh, Urban Airship, One Signal, Parse.com, etc.) to register the device with your push service (this could be a push service you set up yourself!). No need to collect any additional data for Apple or Google’s use. I also don’t think most push providers want any personal information. Though you may need to collect things like segment information (Person wants Sports pushes, Weather pushes, Traffic alerts via push for say a news app).

C7. You don’t need a push or local notification for this. You want something like native.showAlert() to notifiy the user there are new messages.

In your C example, all interactivity is triggered by the app user. They wake up their app and checks the server for new data. There is no reason to use push notifications in this model. Now if you change your model where you want to let your user know there are updates without them checking your app periodically, then push notifications will be a great tool for you.

Rob

Thanks Rob!

A- Cleared!  :ph34r:

B- Cleared! :ph34r: (Maybe in the tutorials a very little note about it would be nice for other newbies)

C7-But the user didn’t open the app again. He just reopened the phone and plays a game in the phone or walks around with his crush instead of opening the app :)  According to my model, this checking should be done with background process. However background process is not possible with Corona as I know? Is there any way to send a data to an inactive app?

Then you probably want to use push notiifications. You’re server will have to have a way to send the push though.

Rob

Well I still couldn’t solve it.

Any idea?

based on what you said, it looks like it can be done. The app can get data from your server or from the push-notification sent (4kb of data using event.custom )

https://docs.coronalabs.com/guide/events/appNotification/index.html

@yosu

Greetings

Yes the real solution is push notifications. However I am trying to figure out the system of push notifications and background process. Also because I didn’t understand the general process of them, I am looking a solution without push notification  :)  :ph34r: is it possible?

Hey Ersinerchin,

I will try and help you out, I did have background mode (GPS and queries from Parse) working on iOS before the iOS9 update, and I’m currently working to get it back. I potentially had it spoofed and thus it was patched, but it did work till then.

If I figure it out again, I’ll let you know.

Regards,

Aidan

So in the end, we couldn’t solve it :frowning: we need to use only push notifications…

a- If the app is not working in the background, how can it take push notification? Or how will it come?

b-“The app has to support a registration process and it must support incoming messages.” Could you explain details of this issue? Should the app have a process for users about registering the system by email, name etc? Or something different?

c- I am good about using rss feed systems. I can trigger local notification when the user starts the application. But I want to trigger it with my command. Lets be more clear:

  1. The user installs the application. (11:00)
  2. The user opens the application. (11:30) It checks the rss and store some data.
  3. The user closes the application or close the phone (12:00)
  4. The user opens the phone. (14:00)
  5. Phone checks if there is a new content or not (15:00) No new content, no new notification .  Because the data is still same with no 2.
  6. The admin gives a new content by rss (18:43) 
  7. Phone checks if there is a new content or not (19:00) Phone detects a notification because the rss is different from no 5 or no 1.
  8.  It triggers an local notification. Notification pics come from local files of the app. 
  9. Phone gives an local notification (19:01)
  10. The user notices the notification by sound or by shake (19.01)

Extra - The admin gets a feedback from the app that if the user gets the notification or not (Not very important section)

I tried to write very clear. I am not looking for coding of course but I am trying to figure out that if it is possible with corona or not.

a - Push notifications do not require the app to be running. On iOS the OS handles the notification. On Android, I believe it calls part of your program (which Corona does under the hood) to handle  the notifiacation.

Depending on the state of the app, how the app handles the push varies:

  1. App is not in memory, use interacts with the push:

In this case, the OS starts your app and you will get a launchArgs table set that has the data from the push notification in it.

  1. App is not in memory, push comes in, but the user starts the app from it’s main icon:

The app gets no information from the push notification. No events are generated, no launchArgs is set.

  1. The App is in the foreground running:

The App will get a notification event and your app should handle it as necessary

  1. The App is backgrounded, user interacts with the push:

App is foregrounded and receives a notification event.

  1. The app is backgrounded, user starts the app from it’s icon.

Like above, no push events are generated and there is no way for the app to get info from the push.

B. When your app starts up, you will get a registerDevice event. This will include a really long hex string that identifes your device. Corona will automatically send this data to Apple or Google (if you have things setup correctly) to register the device-app combination with their servers than send push notifications. Then it’s your responsibility to respond to the register event and update your push notification sender (PushWoosh, Urban Airship, One Signal, Parse.com, etc.) to register the device with your push service (this could be a push service you set up yourself!). No need to collect any additional data for Apple or Google’s use. I also don’t think most push providers want any personal information. Though you may need to collect things like segment information (Person wants Sports pushes, Weather pushes, Traffic alerts via push for say a news app).

C7. You don’t need a push or local notification for this. You want something like native.showAlert() to notifiy the user there are new messages.

In your C example, all interactivity is triggered by the app user. They wake up their app and checks the server for new data. There is no reason to use push notifications in this model. Now if you change your model where you want to let your user know there are updates without them checking your app periodically, then push notifications will be a great tool for you.

Rob

Thanks Rob!

A- Cleared!  :ph34r:

B- Cleared! :ph34r: (Maybe in the tutorials a very little note about it would be nice for other newbies)

C7-But the user didn’t open the app again. He just reopened the phone and plays a game in the phone or walks around with his crush instead of opening the app :)  According to my model, this checking should be done with background process. However background process is not possible with Corona as I know? Is there any way to send a data to an inactive app?

Then you probably want to use push notiifications. You’re server will have to have a way to send the push though.

Rob