I've been looking for a way to compare timestamps between applications on the same phone in real time, and NSDistributedNotificationCenter sounded like an ideal solution since i may not know the names of the apps listening for it, but it sounds like its not available in iOS.
Is there an equivalent way of notifying multiple apps of a time-sensitive event without knowing their name?
Coding for iOS 5+ and assuming the apps in question will register for the notification.
Look at CPDistributedMessagingCenter in /System/Library/PrivateFrameworks/AppSupport.framework. However, it's a private framework (may change with OS releases, and not allowed in AppStore).
Documentation here: http://iphonedevwiki.net/index.php/CPDistributedMessagingCenter
Example codes of mine here:
https://github.com/H2CO3/PwnTube
https://github.com/H2CO3/Cereal
I'm pretty sure you can use Mach ports. They are a bit low level but work well.
i found a way to use CFNotificationCenterGetDistributedCenter() on iOS. It is exists on device, but not exports in iOS SDK
void *libHandle = dlopen("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation", RTLD_LAZY);
CFNotificationCenterRef (*CFNotificationCenterGetDistributedCenter)() = (CFNotificationCenterRef (*)())dlsym(libHandle, "CFNotificationCenterGetDistributedCenter");
if(CFNotificationCenterGetDistributedCenter) {
CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), NULL, &NotificationUpdateApp, CFSTR("TestApp"), NULL, CFNotificationSuspensionBehaviorCoalesce);
}
dlclose(libHandle);
Not really. The closest you can do to what you’re asking, on a non-jailbroken device, is have your server talk to each other app’s server and have that server send a push notification to the app in question. Without NSDistributedNotificationCenter (which is, as you surmise, not available on iOS), you don’t really have any other option.
This question is a little bit old, but I'll post my answer just for information purposes.
NSDistributedNotificationCenter is not available for iOS yet, and unless your are developing an app that you don'd pretend to release on AppStore, you can't use AppSupport.framework because it's private.
iOS8 released App Extensions, that give us the ability to communicate with other apps. I don't know what you are trying to do exactly but I believe that if you are just trying to compare some timestamps from some other apps, it should resolve your problem.
Link to AppExtensions documentation:
https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/
Hope it helps somebody.
NSDistributedNotificationCenter exists on iOS, but the headers aren't made available to developers.
Create a header file in your project with the following to make the class available:
#interface NSDistributedNotificationCenter : NSNotificationCenter
+ (NSDistributedNotificationCenter *)defaultCenter;
// Returns the default distributed notification center - cover for [NSDistributedNotificationCenter notificationCenterForType:NSLocalNotificationCenterType]
- (void)postNotificationName:(NSNotificationName)name object:(nullable NSString *)object userInfo:(nullable NSDictionary *)userInfo deliverImmediately:(BOOL)deliverImmediately;
#end
This is very useful when trying to get information from an App to its UITest runner, but you should obviously NOT attempt to put this in the AppStore.
I've created a project XCTestBackChannel to show this off.
Related
I agree that this question is duplicate. Please bear with me. I was also among you all to believe that is not possible to programatically turn on/off bluetooth.
But using GKPeerPickerController if bluetooth is not on user will be prompted to turn it on. Fair enough to turn on the bluetooth.
I was betting with my belief that we can not turn off the bluetooth programatically as there is no way. But this application does that so I didn't had choice to refuse.
I just want to confirm whether it is possible or not and if yes how to turn off the bluetooth using GKPeerPickerController or any other public api way ?
I know this isn't the answer you want, but no, you can't turn off bluetooth programmatically with Apple-approved APIs.
There have been a number of apps approved on the App Store this year that have done this.
But, they keep getting removed by Apple shortly after release, once they (Apple) realize what's going on. They're certainly using private APIs.
Either developers are foolish enough to think that they won't be noticed, or they are simply hoping to pull in a couple weeks of revenue before Apple pulls the app, which could be enough to pay back their cost, with some profit.
The issue is that there's a number of ways to check whether an app is using private APIs. If developers are using objective-C frameworks in the normal way, that's an easy check. In fact, Xcode does some of this automatically when you use it to upload app binaries to iTunes Connect. But, it's not a complete check. Once at Apple, the reviewers perform another check, which I've been able to deduce is more sophisticated than what Xcode does.
However, that check is still not perfect, and I'm of the opinion that it's not necessarily a matter of a lazy reviewer just forgetting to perform the check. Objective-C gives you some techniques for obfuscating method calls. Depending on how you use these techniques, you might get past the reviewers . In my experience, I have every reason (wink, wink) to believe that Apple is not running every app on a fully instrumented version of iOS, which could log all function calls, and defeat even the best attempt to hide private API usage via obfuscation techniques.
So, I can pretty much guarantee you that this explains the apps you've found on the App Store that turn off Bluetooth. Public GameKit APIs let you turn Bluetooth on, but not off.
Disclaimer: I've never worked for Apple, and no Apple insiders gave me information. But, I have gotten private APIs through the review process.
Please try below code and I think it will also work for you.
Class BluetoothManagerClass = objc_getClass( "BluetoothManager" );
BluetoothManager *btCont; = [BluetoothManagerClass sharedInstance];
[btCont setPowered:NO];
You need to add BluetoothManager class/framework in your project.
Thanks
I need to implement a communication between a central app that runs always and other apps that may request services from that app. There should also be a way to communicate back to those requests even if they have been closed (i.e. loading them to get the responds). What is the best way to implement that on iPhone? (on Android a solution could be done using StartActivity)
Thanks
On the same device? Impossible with official APIs.
If jailbreaking is an option, try the CPDistributedMessagingCenter class. It has a very good documentation on the iPhone Dev Wiki (just google it). You may also want to look at how I used it one of my tweaks: see the daemon's implementation on GitHub.
is it possible to wake an App in the background up, when a call comes in, and access CoreTelephony to send some infos over the web?
I'm practically a n00b in iOS development right now, but got asked a question if iOS is capable to do this. I searched in the iOS reference too, but with no luck.
It would be great if someone with more experience could answer it. Thanks a lot!
Steno
Please, have a look at the document about executing code in the background.
If you go to section "Implementing a VoIP Application", you will see that it is actually possible for your app to be awaken periodically so that it can check if it has anything to do (in your case, if I understand you correctly you would use CTCall to check for calling state).
So, basically, when awaken, your app could check for any incoming call and then use Core Telephony, as you say.
The only trouble about this is that if your app cannot be considered to a a VOIP app, Apple will not let it into the App Store.
It is not possible to have your code run when a call is received.
My question is simple but I haven't found a good answer anywhere. My question is this: Is there a way through either the iOS SDK or third-party frameworks to get cell tower location data? Meaning cell tower location, distance from you, etc.
The signal application for iOS does this, so I know it's possible, but I can't seem to find any documentation or resources on the matter.
Thanks!
There is no official way to do this as far as I know.
iOS SDKs abstract that info to a single and easy to use location API.
The application you link is probably using private APIs from iOS.
That means that developer is using undocumented functions from iOS.
If you really want to find more about it, you can try contacting him.
Also check this:
iOS Private API Documentation
The signal app used some private API which will lead to immediate rejection by Apple, which is why it says jailbreak device only.
Plus, you may find this post helpful: iPhone signal strength
The CellStumbler application (CellStumbler at code.google.com) uses undocumented methods in the CoreTelephony framework. There is a CellInfo struct defined which can be queried via the _CTServerConnectionCellMonitorGetCellInfo method.
However, on iPhone-4S - iOS5 the CTServerConnectionCellMonitorGetCellCount always return zero - so no cell info can be queried. Things may look different on a iPhone4/3S since Apple changed the baseband modem from Infineon Gold to Qualcomm mdm6610.
You mal also try to evaluate the built-in FieldTest app (just dial *3001#12345#* to start) which gives you a couple of info related to your cellular network status.
I want to add something (eg. the related city name) into the UI view when I make a phone call or received a phone call on iPhone. However, I can't figure out a good solution for this idea. Could anyone who has experience on this subject gives me some suggestions?
My currently solution is, try to write an extension based on mobile substrate and hook functions in SpringBoard. So many difficulties existed and following are my current big questions,
How to develop such a extension? I downloaded some examples from google, unfortunately they cann't even be compiled on my toolchain.
I can't figure out which ui view for the related screen I should use to insert my own component. I get header files of SpringBoard via class-dump, but no docs and no comments about its usage. Could someone share his discoveries with me?
How to build a trusted cross-compiling enviroment on leopard? All kinds of confusing errors pop up when I try to build others's codes. I've tried Zdziarski's instrunctions in his book, it works with iPhone OS 1 and can compile common projects with open sdk, but how should I do to make it works when comipiling ms plugins?
Also, is there any other solution to translate my ideas to codes? I start iPhone development one month ago, no experience with cocoa/Obj-C before. So your suggestions are very appriciated.
~ Link Bian (卞林扣)
Email/MSN: linkou.bian#gmail.com
I think you are asking for too much. It wont be possible to manipulate incoming/outgoing call screens. Ethically, that is.
Zdziarski is a hacker and from his book, you will get many undocumented API calls which will make Apple reject your app. Same goes for Erica Sadun's iPhone Developer's Cookbook.
Something that really helped me get dylibs compiled was using SkylarEC's Xcode template and just appended an extension of '.dylib' onto the binary and sshing it into /Library/MobileSubstrate/DynamicLibraries. I suggest hooking SBCallAlert or SBCallAlertDisplay to get the id of the caller which is usually just an NSString. Play around with it a little bit, those are all the visualizing methods of a call. If you put in an nslog in your custom override method, you can view the output in iPhoneConfgurationUtilitie (windows) or the console in Xcode. From there you would most likley need an index of area codes to comare the callers to. I don't believe you can add subviews to the call, on I intercept and reissue the strings for the views already there.
But you know, apple doesn't like this :P
lemme know if this helps