Toggle iPhone Charging through OS X or XCode - ios

I'm currently writing an iOS application and am receiving battery status change notifications. Of course, when I'm debugging my app it would be nice if I could toggle the battery status without unplugging my phone. Is there any way to do this via OS X or XCode, that is, while having the phone plugged in tell it to stop charging so I can test my notifications and actions?

Due to Apple's sandboxing regulations and firmware, you can not tell the phone to stop charging. This is a service extremely close to the core of the phone, and it can not be programmatically accessed.

Of course, when I'm debugging my app it would be nice if I could toggle the battery status without unplugging my phone.
Since you can't do that (per the accepted answer), an alternative that will help you debug is to create and send your own battery status notifications. The notifications are regular old NSNotification objects, and you can create and send your own with the name set to UIDeviceBatteryLevelDidChangeNotification or UIDeviceBatteryStateDidChangeNotification. That should let you trace through any code that would normally run when your app receives those notifications.

Related

Ios Application connected in Background with device

i have an application that is connected with a chip by bluetooth.
Device and phone are constantly connected to calculate the distance between them by bluetooth delay in reply.
App is working fine in foreground.
When i go background the app is still running, but cannot connect to the device.
I already tried to fix with this guide: Core Bluetooth Programming Guide
but i didnt made it.
Some suggestion?
You need to introduce more detail.
Your app will not run in background mode even bluetooth connection is on.
But your app still have a chance to execute some code in a short time if some bluetooth event happen.
Connection lost.
Notification received.
If your application work like anti-loss bluetooth tag, you need
Enable background in iOS app.
Write your code in core bluetooth delegate.
And One reminder: Calculate distance based on bluetooth relay is not smart. Bluetooth communication is not designed to support this kind of feature.
It work on license free 2.4G band and human body has big impact on it.

IOS 8 Silent push notification not working without Xcode

I'm trying to test out the silent push notification and I notice that my Iphone (IOS 8) can only receive silent notifications when my device is connected to Xcode. While it is unplugged, I can only receive one silent push in probably 5-10 tries. This only happen to IOS 8 because I have another phone which is running on IOS 7 and not even a single silent push is missed. Anyone face the same issue ?
More details:
If the phone is connected to power source, I'm able to get silent push notifications perfectly...
I have encountered similar issue. If my iPhone connects to the Xcode, it can be woken up successfully by silent push notification. However, if it disconnects to the Xcode, silent push notification can ONLY be received without being woken up to perform background fetch.
The root cause for my case is that I turned off the "Background App Refresh" on my device. ("Settings > General" > "Background App Refresh")
After I turn it on, my iPhone can work as expected again.
Good Luck!
Seems like you are using Debug certificate while interacting with APNs from the server side. And it only works while a device is in the debug mode.
For untethered push notification handling, you need to use Release certificate.
This article would give a better understanding on using certificates with APNs:
https://quickblox.com/developers/How_to_create_APNS_certificates
Sounds like a network issue to me. Are you sure that the PNs are actually delivered to your phone?
You could disable cellular radio (PNs are always delivered over cellular data even if on wifi) and use, e.g., tcpdump in promiscuous mode on your local wifi in order to see if there's anything coming in. Just look for packets from 17.x.x.x. Apple warned us they'd rate limit silent PNs, maybe that's the issue here (while that wouldn't really explain why it works while your phone is plugged in).
I know this questions is old but, according to Apple documentation, receiving and processing of silent push notifications depends on the conditions of the system, so I think that because you have a power supply, device will not throttle the delivery of notifications. Here is what Apple says:
Important
The system treats background notifications as low-priority: you can
use them to refresh your app’s content, but the system doesn’t
guarantee their delivery. In addition, the system may throttle the
delivery of background notifications if the total number becomes
excessive. The number of background notifications allowed by the
system depends on current conditions, but don’t try to send more than
two or three per hour.

BLE Notification when the application is not running

Is there a possibility to receive BLE notification in your application for a specific UUID or whenever any UUID gets in range while the application is not running? E.g. the same way Push Notifications work?
I tried to google around but so far no helpful information that I could achieve. Any pointers?
Checkout background execution modes. The app does not need to run in foreground in this case, but it needs to have been started before and has to be in background at least.
iOS7 introduces a Bluetooth state preservation and restoration for long term Bluetooth tasks. By these means, even a terminated app will be restored in background mode by the os.
This is now possible after the iOS 7.1 update

Bluetooth beacon launch app or generate push notification

Is it possible to achieve something like geofenced launching of an application, but using bluetooth beacons instead of GPS? I.e. when the phone gets a close to a device with a particular id it will launch the app (or somehow generate a push notification which could in turn launch the app)?
No, not in iOS 6 or 5. You would be interested to look at the docs for the upcoming release however. You might find something in there to be pleasantly surprising.

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