How to get network interface info (e.g. 'en0') on iOS? - ios

Some of the iOS API's (e.g. DNS-SD) provide info by giving you the int index of a network-interface (e.g. "1").
But Apple's own API for querying network-interfaces - SystemConfiguration.framework - has those API calls blocked/deleted/MIA for iOS (they're all marked as "OS X only").
How do you query these interfaces on iOS?
(FYI: use-case is: "With iOS, Apple officially requires you to manually inspect interfaces returned from DNS-SD requests to decide which ones are bluetooth versus wifi. Apple gives us an interface index, but no further info")

I don't understand why the SystemConfiguration calls are missing from iOS, but it seems you can use the standard ifaddrs.h calls to get some of the core info, as per this SO answer:
https://stackoverflow.com/a/13279757/153422

Related

Discovering services via Bonjour on iOS 14

I'm having trouble understanding privacy constraints for local network service discovery using Bonjour on iOS 14. Here is what I found:
Using NetServiceBrowser, I'm able to discover services using:
browser.searchForServices(ofType: "_services._dns-sd._udp", inDomain: "local.")
I have to add a couple of keys to .plist file, but it works.
However, if I turn to NWBrowser, and try to run the same request, I get an error:
nw_browser_fail_on_dns_error_locked [B1] Invalid meta query type specified.
nw_browser_start_dns_browser_locked failed: BadParam(-65540)
I gather, this means I need the multicast entitlement.
Now, the question is, why would I go through all the trouble of requesting multicast entitlement from Apple, if I just can use NetServiceBrowser instead of NWBrowser? Doesn't NetServiceBrowser defeat the purpose of obtaining multicast entitlement?
According to the docs this error means that you passed an invalid value to NWBrowser - most probably it's the format of the service you're trying to discover.
You haven't posted your NWBrowser code, but for example, a wrong formatted service such as _example_.tcp would probably result in the error you're seeing. Make sure it is in the correct format, which should be something like _example._tcp..
Another thing you need to do is modify your Info.plist file and add two keys:
Bonjour Services - this is an array, the first item should be the service you're trying to discover, in my example, it is _example._tcp.
Privacy - Local Network Usage Description - that one takes an explanation text which will be shown to the user the moment you start discovery with NWBrowser.
Now regarding the entitlement you mentioned: it is only needed for apps that scan for all services on the network and not a specific one like in your case. I encourage you to watch this video, which explains everything I wrote here.
Lastly, why should you use NWBrowser over NetServiceBrowser? That's a very good question which I'm also trying to figure out the answer for 😆
The multicast entitlement is only required if you're scanning for all services. If you're scanning for a specific service - you don't need it
In iOS15 - if you do not have the entitlement you can not do
browser.searchForServices(ofType: "_services._dns-sd._udp", inDomain: "local.")
The reason to use NWBrowser is that it is the new api - NetServiceBrowser is deprecated. At some point - Apple will (probably) simply remove NetServiceBrowser. It's pretty deeply ingrained in a lot of software though - so I don't see them removing it any time soon.
NWBrowser is a somewhat easier API to use as far as straightforward browsing goes.
Note though - that if you want to resolve a service to get an IP address, you'll need to use NetService anyway...

What sections of Apple Health app are available via the x-apple-health:// URL scheme?

I want let users view the Weight section of Apple's Health app to allow them to see detailed data, etc. I manage to open the Health app via the URL scheme x-apple-health://, but I would like to send them directly to the right place, e.g. x-apple-health://HealthData/measurements/Weight. I have had no success after trying different paths that made some sense.
Anyone has a reference on this?
Apple has not documented the x-apple-health:// scheme for use by apps. Attempting to use it is like using SPI - even if you find something that works now, it is likely to break in a future version of iOS. You should file a Radar with Apple to request an API for this purpose.

How to display view contact on call screen and get info comming call?

I want to display a view on call screen of iPhone and get info comming call but I can't.
I found one link access private API but it saying that apple will not approve this,
But i saw some application on appstore.
Link
https://itunes.apple.com/au/app/contact-notes/id660212820?mt=8
Can any body tell me how to do this?
You may have luck using the APIs in the new CoreTelephony framework Apple added, specifically the CTCall class. This doesn't reveal the caller, but it may be possible to somehow get that.
Using private APIs in any way is not recommended and will break on future releases of the OS, and it's doubtful if you'll even get in the App Store using them. Don't do it.
It's possible that the application you cited as an example uses these private APIs, seeing as it has iOS 5 compatibility. If you really need to use that API, it's possible to obfuscate your use of it with method swizzling, or getting function pointers and calling those, although that can will break when Apple changes their private APIs.
Lastly, you could download and install this app, then dump its symbols to see what APIs it uses.

Share data across multiple apps on iOS

I know there are quite a few threads on this, but it seems none of them would satisfy what I am trying to look for. Here's my constraints:
not a hack that uses private API/framework or undocumented
directory access that would run the risk of app being rejected
because of that
being able to share data across different
vendors / app developers
data can persist outside the lifecycle
of the app (even after app is deleted)
UPDATED: I was in general trying to stay away from using a 3rd party cloud-based service to achieve the goal as this would introduce additional external dependency. But if I have to, I was hoping it could satisfy this one constraint
being able to tell which iOS device it is communicating with. It shouldn't have to uniquely identify the device (which will go into that evil UDID discussion route as we all experienced ). But as long as it can differentiate among different iOS devices it should be fine.
I kind of need this too. I use Parse.com as the backend of all my apps — their free tier should satisfy your development needs.
Parse has APIs available for iOS, Android, Windows 8, OS X, JavaScript and .NET, with all your data available on the cloud on any platform (contrary to Core Data and iCloud). They also offer "Cloud Code," which is code you can execute remotely, to process information remotely and get the data back to your app.
You should definitely check Parse.com out for cloud storage for your app. In my experience, it really gets the job done.
For Data Persistence, I think you might want to take a look at FMDB (although if you decide to persist data locally, it will get deleted with your app, but it might help you, anyways). Core Data is an overkill in many cases.
Edit: Parse.com has an "Installation" class, in which all the devices that have your app installed get listed (wether they're running iOS or Android), uniquely, without you having to type any code.
Maybe this blog post by TextExpander authors will help:
Smile has responded to this by discussing the issue with Apple
engineers at WWDC, filing a bug (#14168862), and checking up on the
status of that bug. We also developed a workaround by storing the
TextExpander data in a new place. Reminders requires user consent to
store and retrieve data. Completed reminders are not normally shown in
its interface. Long-past reminders appear at the bottom of the
completed reminders.
TextExpander touch 2.1 (and later) supports storing shared snippet
data in a long-past, completed reminder. We produced an updated SDK
and kept our developers posted on its progress. Our final SDK was
ready within a few hours of the end of Apple's official iOS 7
announcement.
UPDATE (22.11.2013)
This might not be the best way to do that, because TextExpander's team recently had problems with the App Review Team.
Edit: this only works for apps with the same vendor.
You can save a password to the device's keychain, then access that password from any app.
Using the SSKeychain library...
NSString *service = #"com.yourcompany.yourservice";
// read
NSString *password = [SSKeychain passwordForService:service account:#"user"];
// write
[SSKeychain setPassword:password forService:service account:#"user"];
The password string doesn't have a length limit, so encode all your data as a string and save it there. The keychain entry will persist after the user deletes the app.
One of the ways to do this is using THRIFT. This is a data communication protocol that would need a back end server (private) and THRIFT can be compiled into many languages / platforms. There is a meta language to describe the data and then can be thrift compiled into many languages. Write the data definition once and can be used on many platforms.
More information at.
http://thrift.apache.org/
for me (I have 2 apps and a widged) the best solution is using SSKeyChain and do not forget to add Capabilities for your apps like here
or if you don't wanna to use 3rd party library you can use NSUserDefaults and set the group identifier like here but again do not forget to add the group identifier in Capabilities in AppGroups section for all your apps that have share data.

UIEventSubtype missing elements

The enum UIEventSubtype (iOS UIKit Framework) contains events such as play, pause, next, seek, etc. However, the iPod Access protocol contains numerous other events, such as select, up, down and back (think iPod with clickwheel). The iPod app on iOS can receive these other events and respond accordingly (move selection up/down/back in playlists), but developer apps don't have seem access to these controls.
Does anyone know a way to receive these additional events in an iOS app (for jailbreak), other than opening the /dev/tty.iap port myself (or filing a bug report with Apple and waiting)? Perhaps there's a private framework that has what I'm looking for? I looked in the IAP framework but didn't see anything interesting.
#Victor Ronin had the right idea, in the Private Framework iPodUI I found a class IUAccessoryEventHandler containing methods like
- (void)handleDownArrowEvent;
- (void)handleUpArrowEvent
- (void)handleSelectEvent
When I hooked into them with a Theos tweak and inserted logging details, I was able to see that these methods were the ones being called when an external device was sending the commands.
Update: Unfortunately, the iPodUI framework were only available in iOS 5 and 6, according to the iPhone Wiki. Not sure if or where these methods are still available.
I don't have a ready answer for you, but since you are doing this on jailbroken device, you can use mobile substrate to inject code into iPod app and you can override UIApplication sendEvent to see all events, which it receives (including select, up, down etc).

Resources