PushSharp Push doesn't process queue until stop - ios

PushSharp only processes the queue when stop is called. Does anyone have an idea how often push sharp will process the queue or flush it? I don't want to have to call stop and start every time I want to send a notification to conserve resources.
pushService = new PushService();
pushService.StartApplePushService(new ApplePushChannelSettings(prod, cert.InputStream.ReadToEnd(), passConfig.Value));
pushService.QueueNotification(
NotificationFactory.Apple().ForDeviceToken("mydeviceid").WithAlert("Notifications Started!").WithSound("default").WithBadge(7));
pushService.StopAllServices(true);

I'm a complete and utter idiot...
The main thread was completing execution before the queue timer could process the notification. StopAllServices forced the thread to wait... Maybe this will help someone else.

Related

App in Background : task stopped

My app while in background receive pushes to trigger some background tasks, scheduled in a NSOperationQueue.
The first NSOperation terminates correctly, but the second doesn't terminate, it seems like the task is paused, and when I put the app back in foreground the operation can terminate like it should.
Is there restrictions for background tasks ? (The tasks take about 2 or 3 seconds to execute)
Thank you
you have enable any of the background service like Location , Background fetch , Remote Notification to enable active your app in background mode. Please below apple link where you may get more idea -
https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html

Saving in Background Thread not getting finished

I have an instance of AVAudioRecorder and I have noticed that when the user closes the app too fast with a larger recording the file does not get saved properly.
This even happens when I call [recorderObject stop] in the main thread and the file gets saved locally.
I have also tried moving the file after the recording has stopped (in the (void)audioRecorderDidFinishRecording:successfully: method). But I have noticed that when I do the move with NSFileManager in a background thread with high priority, it too doesn't always finish.
Is there a way for me to insure that the files get saved, even if the user exits the app shortly after finishing a longer recording?
Thanks
Review Apple's documentation for executing tasks in the background.
Apps moving to the background are expected to put themselves into a
quiescent state as quickly as possible so that they can be suspended
by the system. If your app is in the middle of a task and needs a
little extra time to complete that task, it can call the
beginBackgroundTaskWithName:expirationHandler: or
beginBackgroundTaskWithExpirationHandler: method of the UIApplication
object to request some additional execution time. Calling either of
these methods delays the suspension of your app temporarily, giving it
a little extra time to finish its work. Upon completion of that work,
your app must call the endBackgroundTask: method to let the system
know that it is finished and can be suspended.

Call method from background

I want do code an alarm-clock.
Now the alar-clock should play a music-file at a specific time.
But I don't know how to call the method with AVAudioPlayer while the app is in background?
Can you please help me I want do this for the first time.
thanks :)
You should not use a long-running background thread in order to trigger a sound at a certain time. A running thread prevents the device from going to sleep, greatly increasing power requirements.
Further, Apple greatly restricts the amount of processing you are allowed to do from the background. You can request time to complete a long task from the background, but only a short period of time is allowed. (A few minutes at most if memory serves.
You should probably create a local notification instead. The local notification will display a banner message on the lock screen if your app is not running, and optionally play a sound that you specify.
Take a look at the UILocalNotification Class Reference in Xcode for more information.

iOS background uploading of images

I have made an application which uploads a bunch of photos to a web server. It does so by repeated html calls, using multiple AFNetworking's AFHTPRequestOperation inside an operation queue. Right now, of the user exits the application, the queue stops. However, I want to continue the uploading queue until it's done, and then let the application go to sleep like it normally does.
I know that iOS provides a background expiration handler using "beginBackgroundTaskWithExpirationHandler" . I also know that AFURLConnectionOperation which is superclass of every HTTP operation class in AFNetworking can use that using
- (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler
But is there any way of making this work with an operation queue? Will setting the expiration handler of each operation do the job properly if I want to upload, let's say 10 photos?
I would appreciate any comments on background tasks with AFNetworking, or if anyone has experienced the same problem as me.
When an app goes to background, the OS will decide whether or not to completely stop your app or give it some time to complete what it's doing. In case it wants your app to stop, the expiration handler is called. If that's happening you should suspend all your tasks as fast as possible and prepare for a complete kill of the app, because that is what will happen a very short time after (5 seconds max). Take a look here.

Grand Central Dispatch when program enter suspended mode

Let's assume that I have a GDC thread running when the app goes inti suspended mode. What will happen? Will the tread stop or continue running? Or do I have to stop it myself, in that case how is this done?
Thankful for advice!
Background State & NSThread
The system automatically suspends all threads include GCD threads.

Resources