iOS Question May the app be killed by the OS ?

marcick

Well-Known Member
Licensed User
Longtime User
This is not still clear to me, because we don't have services like in B4A:

I have a timer that each nn seconds make a request to a server (RDC) and then show notifications or play sounds based on the result.
I see everything continues to work in background when I press HOME.
Does it exist the possibility that the OS kill the app after some time ?
If yes, any solution to prevent this ?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Does it exist the possibility that the OS kill the app after some time ?
If yes, any solution to prevent this ?
The app will be killed after a short period.

The only real solution for this specific case is to use push notifications (unless you don't plan to release the app through the app store).
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
@Moster: I had a look and more or less understood, but don't know how to translate it in B4I.
@Erel: what do you mean, that I have to push all devices every n minutes to restart the app if not running ?
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
Need to study around all these informations.
Usage of background location tracking is refused by the appstore ?
If I'm not wrong the max devices for an ad-hoc distribution is 100, I dont' like this limit, so I was thinking to use the appstore for a standard distribution.
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
If this is a non-app store then you can use background location tracking to keep your app running in the background.

I'm looking to that sample, but if I understand well this does not allow my app to do something every n seconds in background, but just to do something everytimes the location changes, right ?
I need to poll a server via RDC every n seconds also when the app is in backround and if some kind of data are received produce notifications an sounds.
Is it possible in some way to accomplish it ?
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Send a silent push notification (you have about 30 seconds to do something, for instance to pull data from your server and analyze it) and if you need to notify your user, you can use a local notification. I don't think you can use it for "every n seconds" but every 2 minutes should be OK (I tried every 3 minutes and most silent push notifications were delivered to the device).
If you app gets killed or suspended, silent push notifications won't work and you will need to use standard push notifications to ask user to start your app again (or whatever you seem fit).

Silent push notifications:
https://www.b4x.com/android/forum/threads/silent-push-notifications.56016/
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
@Erel: I have added a timer in the sample that do something every 3 seconds and I see as you say that the task are executed also in backgroung. That seems to solve my problems, but you told me that the app could be refused by Apple because they could look inside the code and see I'm not using the background location as it is intended for, right ?

@moster67: Something like this ?

1) write a B4J app for my server, that works as a push server and also check the server database every n seconds
2) if there are new data send a silent notification to the registered users that are interested to that data
3) the app of the users receive the silent notification and poll the server via RDC to collect the data

A bit complicated, need to rethink from scratch all the platform, but I realize that would be a much more efficient way instead of let each user to poll the server contonuously.

I have a hate/love relation with Apple: you are nervous when they doesn't allow to do something, but on the other hand they force you to "think better" and write more efficient software.

Update: i need to correct what I said to Erel. Timer tasks are execuded also in background in the Local Mac simulator. But on real device Iphone6S it behaves different: I can see a log for each timer_tick (so the event is fired), but non other codes is really executed (I'm trying to play a sound and make a RDC connection but they are not executed).
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
but you told me that the app could be refused by Apple because they could look inside the code and see I'm not using the background location as it is intended for, right ?
That's true. They will most probably reject it. They don't really need to check the code. They will see it immediately from the plist file.
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
That isn't definitely the way to follow (it doesn't work also). I'll study how push notifications works.
Thanks
 
Upvote 0
Top