NSNotification on device reboot - ios

Is there a way to know when the device is rebooted in ios, like "BOOT_COMPLETED" permission in android. Went through internet and could not find and appropriate answer. Any help would be appreciated.

https://github.com/lithium3141/BootLaunch
You can refer this page but one think, if your app doesn't have voip feature means Apple will reject your application.
Apple State in their document:
https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW1
UIBackgroundModes
voip-The app provides Voice-over-IP services. Apps with this key are automatically launched after system boot so that the app can
reestablish VoIP services. Apps with this key are also allowed to play
background audio.
remote-notification-The app uses remote notifications as a signal that there is new content available for download. When a remote
notification arrives, the system launches or resumes the app in the
background and gives it a small amount of time to download the new
content.
This value is supported in iOS 7.0 and later.
voip key is the technique used most of the voip applications like skype.

Related

How to share data between apps while in background?

I'm afraid I already know the answer of my own question, but I decided to ask anyway before losing my hopes.
I have the following use case: an app writes some bytes in a "shared" resource (let's say on a file) and another app reads the data and sends them to an external device via BLE while in background. Unfortunately, I know that concepts like shared resource and background are bounded in iOS. What I tried so far is:
Using App Group to share data between two apps
This is working fine even in background, but both the apps need to be produced by the same developer team (i.e. Team ID must be the same). This is a problem because one app is not produced by my developer team.
Copying data in the pasteboard
This is not working when app is in background. Data will always be nil and will update only when the app becomes active again.
...and of course there are...
Background limitations
Even though I go for the App Group solution, the only way I can manage to read data and send to the BLE device in background is by starting a background task. This obviously is a caveat: the task has an expiration time (from tests I performed it keeps going for about 3 minutes before being suspended by the OS). I don't need to run a long-time task, but I cannot assure it can be performed completely by 3 minutes or so.
Here's the question: Is there some other solution for this use case or should I finally give up?
If you are using CoreBluetooth to send files to your Bluetooth device, you can try adding bluetooth-central as UIBackgroundMode key in Info.plist of your app.
Apple has mentioned this in its programming guide:
Communicating with a Bluetooth Accessory Apps that work with Bluetooth
peripherals can ask to be woken up if the peripheral delivers an
update when the app is suspended. This support is important for
Bluetooth-LE accessories that deliver data at regular intervals, such
as a Bluetooth heart rate belt. You enable support for using bluetooth
accessories from the Background modes section of the Capabilities tab
in your Xcode project. (You can also enable this support by including
the UIBackgroundModes key with the bluetooth-central value in your
app’s Info.plist file.) When you enable this mode, the Core Bluetooth
framework keeps open any active sessions for the corresponding
peripheral. In addition, new data arriving from the peripheral causes
the system to wake up the app so that it can process the data. The
system also wakes up the app to process accessory connection and
disconnection notifications.
In iOS 6, an app can also operate in peripheral mode with Bluetooth
accessories. To act as a Bluetooth accessory, you must enable support
for that mode from the Background modes section of the Capabilities
tab in your Xcode project. (You can also enable this support by
including the UIBackgroundModes key with the bluetooth-peripheral
value in your app’s Info.plist file.) Enabling this mode lets the Core
Bluetooth framework wake the app up briefly in the background so that
it can handle accessory-related requests. Apps woken up for these
events should process them and return as quickly as possible so that
the app can be suspended again.

Make iOS application run at startup iPhone or iPad

I would like to do my app open when iPhone is turned on. I saw that have some people saying can be using voip key in Info.plist but I tried and can't to do that. Do someone have any idea to help me? Thanks
In short, iphone does not have any access to permission to edit about "onboot" or "onstartup."
Thus, without jailbreaking this would not be possible.
Check the links I provided on your comment.
This would not happen, your app will be active in background through pushkit only when your app dismissed before device goes off.
VOIP - The app provides Voice-over-IP services. Apps with this key are automatically launched after system boot so that the app can reestablish VoIP services. Apps with this key are also allowed to play background audio.
Even with "voip" present in "UIBackgroundModes" in "plist", iOS App does not auto start after device reboot in iOS10
https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW1

VoIP app / restore connection on reboot

I developed a VoIP app and I read from the documentation that a VoIP app automatically restarts on phone reboot. However, DidFinishLaunchingWithOptions is not called on reboot so my connection cannot be restored.
The only way to reconnect is to start it manually it seems.
I can see the app is in memory, because it is quite quick to start when I click on it, but I thought the app should be able to restore its connection without user intervention.
Any thoughts? What am I missing? Is there another callback in AppDelegate that I missed?
The app is capable of receiving remote notifications in this state.
According to
Voip Pushkit notification will not re-launch the app if it was force-quitted and device was rebooted
this seems to work in most cases.
I have not found any official documents on this.
EDIT:
Here
https://developer.apple.com/library/ios/documentation/Performance/Conceptual/EnergyGuide-iOS/OptimizeVoIP.html#//apple_ref/doc/uid/TP40015243-CH30-SW1
is the official documentation on pushkit, which describes that the app is woken up, even if it not running or in background mode.

Sending a notification from OS X to iOS

I have a Mac application and an iOS application. I need to display a notification on iOS, coming from the Mac app.
Is there any easier way to do it than using Push Notifications or network sockets (UDP or TCP)? Maybe Apple provides it away?
I need to make sure that the user hears this notification. The application should launch in the background and start playing sound.
If they are on the same network you can use bonjour ( https://developer.apple.com/bonjour/index.html ) for communication between mac app and iOS app.
If they are on different network you have to use a server, the server will be connected to both mac app and iOS app via tcp, and you can send msgs via the server. And if the iOS device is locked or app is in background you have to implement push notification for sending data to the iOS app.
Not sure of your use case, but using Apple's push notifications to serve notifications for your app seems like a suitable choice. Again, not sure of your use case, but an alternative may be to send a text-message using the Twilio API.
There is another option known as BLE .With BLE you can interact between mac and iOS using core bluetooth framework.
When you receive any message from mac to iOS using this framework you can show a local notification and can wake an app, since BLE also works well in background mode.
For mac to act as peripheral there is a good open source project over here.
you can find more information about BLE here.
Hope this helps.
I think the only acceptable solution is to send push notifications via APNS from mac to iOS device due to limitations on app lifetime on iOS. There is nothing hard in implementing APNS, there are lots of ready implementations, like NWPusher - you may copy it to your project and setup the environment - keys, device tokens - and you're done. To transmit tokens from iOS to your mac app, you may use tons of ways. For example, implement simple web-service on mac and send tokens via http/https.
You may also use a ready server-side implementations, like parse.com, to send push notifications.

Geo Notification on app that is off

Geo Fencing is praised by many, yet I could not easily find an answer to the following.
iOS and/or Android, does an inactive app send you notifications if you are close by?
My question is probably more like: is there an underlying system that knows your app needs to check for your location against the in-app locations and does so despite the app not being active.
Forget the settings where you can switch off geolocation for particular apps, let's assume that is switched on.
But let's assume I just switched my iphone on, no app is running yet. So I am carrying that sleeping phone in my pocket. Would I receive location notifications?
I am currently testing this with Highlight, but maybe someone knows the code/tech side to this answer.
Varies by OS.
On Android, apps can run as a service that are automatically started when the phone boots up. In this case, the user does not need to start the app. So, on Android, yes you would receive location notifications in sleep mode. See http://developer.android.com/guide/components/services.html or https://stackoverflow.com/questions/9866970/tutorial-for-android-services for more info on Android Services.
On Apple, I'm not so sure about running apps as a service like Android. However, I believe there are events that apps in the background can register for. So again, the app (once started) would receive notifications in sleep mode.

Resources