質問

I am working on ios app that used to read ticket data as a barcode scanner. It needs to upload data frequently to a web server, Like two or three times a day. I have done the sync function. I just wanted to run the function when the app is run in background.

役に立ちましたか?

解決

This is not possible on iOS, Apple is not allowing any kind of background service on iOS.

The options you are left with is setting your apps background mode to fetch and implement application:performFetchWithCompletionHandler:. But it is totally up to ios if and when this method is called.

You could misuse one of the other background modes to keep your app open in the background, but Apple might reject your app for doing so. Also user might complain about you app draining battery.

What kind of data is that you need that you have to update it two to three times a day? I would say the when the app is opened by the user would be a good time to update, because this is when the user is expecting new data.

If you need to inform the user about some data changes you should be pull it in the app but a server should send a push notification to inform the user that there is new data.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top