Modify the BLE device name - ios

I am working on an iPhone app and this app send command to a board through BLE module. the board controls some motor to move around.
I do code on iOS app and another guy do the code on Arduino. There is a BLUGiga 112 module on the board.
Now, in my iOS app, I can search out available BLE devices, but the detected device name is not always what I want.
The device name defined in gatt.xml file can always be detected on the iOS app. But I want user to be able to change the name by iOS app while the name in xml is static. So I let another hardware engineer write some code to accept new name from iOS and store in flush and then broadcast back to iPhone. I can pass the name from iOS app and the name is stored in device successfully. But next time, when I open iOS app and try to search around, the new name is not always be detected.
Anybody can tell me why? or what should I do to get the rename function done?

iOS prevents that Service from being usable by a developer. It also caches that data and it is hard to clear that cache.
I ended up making a custom Characteristic that an app could write to. The firmware would handle that write request and then update the device name and advertising packet. It's seems hacky, but I wasn't able to find a better solution.
Section 3.12 (page 24) documents the fact iOS does not let a developer use that Service (and a couple others) https://developer.apple.com/hardwaredrivers/BluetoothDesignGuidelines.pdf

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?)

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

Is there a way to get the search result i get in the App Store app on the iOS device? ( How to get the ipa file of "App Store"? )

Updated on 2015-11-1:
One solution I am trying is to start App Store using Applium, so that I can record/monitor iOS UI elements. just like what we did Selenium.
Let's treat App Store as a standard iOS app, is it possible to:
uninstall App Store from my iphone.
get the ipa file of App Store
unzip the ipa file and get the app bundle
run Appium with App Store's app file
Is it possible to get App Store 's ipa file?
======
I want to know the position of my apps when I search on the App Store. When I use the iTunes Search API. I notice the result returned from the iTunes search API for a specific search term are different from the result on the iOS App Store app.
I found This Question is also about this, the owner of that has find out the reason about this condition.
But there is no answer to solve this problem.
Actually I've been trying to build the search request, but it cames that the iOS Appstore is using the HTTPs request, so I don't know what to do with this.
Hope someone can help, I'll be very appreciate.
There is at this time no way to specify that you want the results you would get from an iOS device.
The most obvious solution that comes to mind is to build a search request that appears as I it came from ios in your app code.
I'm sure its possible to determine that by basically proxying an actual iPhone using say your router on your home network to log the traffic from an iphone.
Once you have that you can then basically reverse engineer the call in your app code.
As you can refer from Apple's guidance: Search API, there are too many ways of parameter combination.(Parameters includes:term, country, media, entity, attribute, callback, limit, lang, version, explicit, etc.) So it's almost impossible to find out the way of combination that App Store is adapting so as to get the same search results as users get directly from App Store.
You might want to see if you can get this to work:
In Mac OS X:
Launch iTunes
Under Library menu, click on [Apps] menu.
The iTunes will display all installed app
Right-click on one of those apps
Then click “Show in Finder” option
An alternative to this is simply open the directory of .ipa files stored by using this path: User/Music/iTunes/Mobile Applications
This probably only works with apps you downloaded, but it is worth trying.
It's possible to listen in on https connections by installing a trusted ssl certificate on the device and running traffic through a proxy - basically performing a man-in-the-middle attack on yourself. I've previously used Charles Proxy to do this - here's the guide how to set this up. That way you should be able to see exactly what request the App Store app is sending and what response it is getting. And thus it should also be possible to spoof this request and parse the results elsewhere.

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.

How Apple TV is used to control Homekit Accesory

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.

Resources