How Apple TV is used to control Homekit Accesory - ios

I have created an application for Homekit which works fine when both accessory and device is in same network.
I read somewhere that Apple TV is required to control accessories remotely.
Can anybody please tell how to achieve this exactly?

No you can not pair homekit with the appleTV. You can use the remote app either from you iPhone or iPad

If you have Apple TV try to set it up.
I have given the details.
I have done a much workaround for this. First of all handling things by our own is not preferable for multiple users.
I had this query that how all configuration done on one device will reflect on another device for same home. Unfortunately apple didn't provided much information on this and they also didn't clarify that Apple TV will require or not(As I have referred to some reports that says Apple TV will use as intermediator between iOS devices.
Now at application side i have tried to add User to home. There is a HMUser class and we can add user to any home that we want to sync. I was running my app in iOS 8.1 in both the devices, I was also logged in to icloud and keychain access was also enabled.
Now i have tried to add user using method of HMHome class
-addUserWithCompletionHandler()
I shows a popup in which we need to enter the email id of user to which we want to give access to current home.
But it didn't work. I always get error "notification not enable at remote side"
I think that login to Apple TV is require for adding user. I am not sure about this, Apple hasn't clarify on this too. I don't have Apple TV if you have try to login in it and use two other iOS devices to give access to any icloud account.
Also revert me if it works.

I have been working on HAP Over iCloud concept since last 2 to 3 hours. The beauty in this concept is according to the documentation we should need the following things.
1. Apple tv 3rd generation.
2. Have to use same iCloud account in both apple tv and iOS device.
3. This is most important that Apple tv and Accessory should be on same network.
Eventhough you are on different network it is able to pass the switch on/off,brightness increase/decrease ... actions. For this you can use siri commands or programmatically call the accessory write value functionality
Note : As I know I think when you are passing the commands to the Accessory it checks for the iCloud account in the apple tv and from there it is passing the commands to the Accessory.

Related

How to read files of External Mass Storage Devices Without DocumentPicker? (iOS)

Just to give some context, there is an iOS app I'm building (in Xamarin) that requires the ability to fetch files (in an automatic way without having the user to navigate to the files and select them manually) that are stored on External Storage Devices (USB Sticks), and are connected (paired) to an iPhone/iPad.
Users connect a lighting cable to the iOS Devices, and plug their USB Sticks into this lighting cable. Here is an example of the cable that end users use to pair the USB Sticks with their iPhone/iPad, and the app then auto fetches these files from the USB Storage Devices.
The app then performs 2 functions:
It listens to notifications, for when a usb stick is paired with the iOS Device.
When it receives this notification, it then proceeds with querying the files on the USB Stick, and reads and processes the files. The app reads these files automatically and the user does not need to manually select these files
I've tried using External Accessory Framework, however that's only suitable for devices that you register with the MFi program.
https://developer.apple.com/documentation/externalaccessory
Notifications Center never seems to work (the Notifications that handle when a Device gets Connected and Disconnected, the delegates never get called), and I've tried using the Microsoft Helpers.
https://learn.microsoft.com/en-us/dotnet/api/externalaccessory.eaaccessorymanager.notifications.observedidconnect?view=xamarin-ios-sdk-12
I've also tried some 3rd party libraries, but haven't found anything useful.
It doesn't look Apple has any Api Available to auto query and read the files, without having to use a DocumentPickerController. I know this is because of the App Sandbox, and I cannot directly access the Removable Storage Devices.
Now for my questions:
Are there any 3rd party libraries anybody can recommend, that can help achieve most of the heavy lifting for this task? I'd prefer a library that's compatible with Xamarin, however if it's a native library (Swift or Objective-C Library, Cocoapods) I'm sure there is a binding I can use on nuget.
Does anybody have any snippets, or documentation, or can point me in the right direction here (Please feel free to post Swift, or Objective-c solutions here if you like)? Where should I look, which Apple Framework (iOS SDK) is most suitable to deal with this situation. And to summarise, is what I'm asking for at all possible on iOS, without having to jailbreak, or get around the App Sandbox?
Update
So I've tried the solution that #Saamer suggested:
Detect if USB is connected to iPhone device
Here is an example I wrote just to verify if the callback gets invoked, and the app can detect if a usb is plugged in.
CFNotificationCenter.Darwin.AddObserver("com.apple.mobile.lockdown.host_attached", null, (e, s) =>
{
MainThread.BeginInvokeOnMainThread(async () =>
{
var picker = await Xamarin.Essentials.FilePicker.PickAsync();
});
}, CFNotificationSuspensionBehavior.DeliverImmediately);
A file picker should immediately get invoked, and open up, once I plug the USB in, however this doesn't happen.
I'm happy for a solution right now which opens up a file picker, when the user plugs in a USB Device, and navigates to the root directory to start off with. So when the File Picker opens up the user should see this. Then they can select the files they want to transfer into the app.
I thought you needed to jailbreak but it seems unlikely, a solution is possible for <iOS 12
CFNotificationCenter's AddObserver seems to be usable for detecting when a device is connected using host attached and detached as shown here
Or if you don’t submit it to the App Store, you can use this
According to the Apple Docs
You can use the Files app and other supported apps to access files stored on external devices, such as USB drives and SD cards, connected to your iPhone.
Essentially you have to make your a "supported app". I have downloaded a free app called "Clockology" that I recommend downloading and playing with, which allows users to see data within the app as you can see below:
You generally use UIDocumentPickerViewController along with the right uttype to get the files from the Files apps or iCloud Drive, and you require activating the Key-value storage and iCloud Documents from iCloud entitlements capability. There's a lot of tutorials on UIDocumentPickerViewController usage, but you specifically want the capabilities that became available from iOS 13 onwards
This video from WWDC is the best example of getting to where you want. I also didn't find any 3rd party libraries that can help with this
——————-
Edit: If the app does not need to be distributed through TestFlight or the App Store, you can use IOKit and distribute through AppCenter, as long as you have the UDIDs of all the devices you need the app installed on (up to 100?)

Open iOS Settings App (top level - not deep link into the App Settings page) - iOS 12/13

I'm working on a iOS App which interacts with different hardware. We access and configure these devices using a "Soft AP" work flow (ie hotspot)
Our preference is to use NEHotspotConfigurationManager to automate the process for the user and in most cases this works fine.
However, in those edge cases where it doesn't (ie iOS 13+ and location services) we'd like to make the workflow as simple for the user as possible.
Currently we have a nice list of steps that the user needs to take:
Press/swipe home
Open Settings
Navigate to WiFi settings
Find and tap the specified WiFi SSID
Return to the App
It's really not pleasant at all.
I'm aware that there is not official way to open the WiFi settings and I can live with that, but recently I was mucking around with the Wyze App and pairing one of their light bulbs and noted that they have manual workflow which opens the top level Settings page - NOT the App's settings. (nb: The Wyze App also has "app settings")
So, after some more reading, I find that UIApplication.openSettingsURLString will open the App's specific settings page, which is cool and everything, but this is not what I need. I'd be really awesome if it was "officially" possible to launch the iOS Settings App and NOT have it open the App's settings, but just land on the top level page.
I know if the App has no settings, this is the behaviour I will get, but our App does (and I can't be changed)
I don't want to/can't use URL schemes like prefs:root unless it can be guaranteed not to be rejected by Apple!
And, yes, I look at a lot of different blogs and questions on the subject, including A Comprehensive Guide to All 120+ Settings URLs Supported by iOS and iPadOS 13.1 - but I'd like to not have the App rejected

is it possible to turn off wifi or switch iPhone to offline mode in codes in swift 4?

I want to know is there any way to turn on or off the iPhone wifi or switch the device to offline mode in codes in swift 4 or not
I know that apple may not allow the app can do such things to be distributed in App Store But it's Not important I just want to know is there any codes to do that or not (Just in swift 4)
5 Solutions Collect From Internet About “How to turn off internet connection, bluetooth and WIFI programmatically?”
Ans
You can’t. Apple does not allow 3rd party apps to change global system settings like that.
There is no API available to control cellular data,wi-fi,bluetooth within in an app , User have to go to settings to enable or disable cellular data,wi-fi and bluetooth.
This is not possible in iOS unless you jailbroke your device. Apple is not allowing any apps developer to access wifi/bluetooth. You can only check wifi/tooth is connected or not.
You can’t do that using the iOS application. Apple not allowing it.
Legally there is no way to do it. Even somehow if you are manage to do it, Apple will reject your app while submitting to AppStore.
update
I am not sure the following code will work or not, try once, initially add the header file to your project folder and create the bridging header to your code ,then use the below code where you need , for ref purpose I taken the answer from here
var tempSBWifiManager: SBWiFiManager = objc_getClass("SBWiFiManager")
// Steal a class from SpringBoard
tempSBWifiManager.sharedInstance().isWiFiEnabled = false

Swift - how to access all pdf files on device

I am trying to build an app that will allow users to see all pdf files that are on the device (in some kind of a list with a preview) [Regardless of which app it belongs to on the device, all should be shown]. Is there anyway to achieve this?
Sorry but this is not possible on an iOS device because of a feature called sandboxing. Apple does not allow an app to access the sandbox of another app. Each app sits inside a sandbox of its own. This is iOS's security feature. There is no way to go around this feature.
Reference - About App Sandbox

Google Cast iOS sample app not scanning for devices

Trying to use this sample app provided by Google: https://github.com/googlecast/CastHelloVideo-ios
It is not asking to connect with my Chromecast, or even scanning for receiver devices. There is only the "Cast Video" button that alerts "Not Connected - Please connect to Cast device" when clicked. I understand there is a whitelisting/registration process for styled and custom media receiver apps, but there is supposed to be a default media receiver app built into the Chromecast that I should be able to use right away. How can I make it scan for devices?
Did you follow the instructions for setting up that app? Unless you use your own App Id or you update the sample to use the default app id, it won't find any device; it is doing the scanning. In addition, please use the GitHub's issue tracker to ask questions about that and other cast samples if you run into any issues when trying to run them.

Resources