cristan lika
cristan lika

Reputation: 425

When sever side adding new item that time how to load table view?

I can not figure out how can i do this my i phone apps have a TableView . that is load by API . it is working fine when application first time open but problem is . when sever side adding new item that time my table not showing that .

how can i do that please help me

currently i done by this way :

NStimer use to 10 second interval re request API to load TableView

timerStart = NSTimer.scheduledTimerWithTimeInterval(10, target: self, selector: #selector(OrderRequestTableViewController.update), userInfo: nil, repeats: true)

but i am sure it is not a good practice to use NSTime to request web api .. there have any alter native option

Upvotes: 1

Views: 166

Answers (2)

SM18
SM18

Reputation: 718

Normal Silent Notification is best solution for this

It "will not show notification alert in notification bar, but it will only notify your app that there is some new data available, when you want to push new content.

Displayed in Notification center : No

Awake app to perform background task : Yes

just add below paylod from server side in push notification { "content-available" : 1 }

{
"content-available" : 1
}

Upvotes: 3

Ajay Gabani
Ajay Gabani

Reputation: 1178

Here is one conceptual and effective solution for your problem.

When you adding any new item on server that time you can send push notification (Silent push notification) to devices to notify status that you added something on server side.

When device receives such push notifications then you have to call API and reload your table view. So you don't have to reload tableview every 10 sec.

Hope this might help you. :)

Thanks.

Upvotes: 2

Related Questions