Is it possible to vibrate watch while Watch Extension is running? We can do it on iOS in this way (force iPhone to vibrate):
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
I hope there is something similar on WatchKit.
Update: I have added issue to Apple radar and recieved the answer:
Engineering has determined that your bug report (20019274) is a duplicate of another issue (19025053) and will be closed.
19025053 is still open.
Update 2: AudioServicesPlayAlertSound() not working on watch simulator with any sound ID. Seems like function is not supported.
You can now ask the Watch to vibrate if you target watchOS 2.0
To do this all you need to do is call playHaptic on a WKInterfaceDevice instance with any WKHapticType. In the example below it will play the notification haptic.
Swift 3
WKInterfaceDevice.current().play(.notification)
Objective-C
[[WKInterfaceDevice currentDevice] playHaptic:WKHapticTypeNotification];
You can further read the
Apple WKInterfaceDevice Documentation
That's a great question, but unfortunately the answer is no. WatchKit doesn't have any APIs available to control haptic feedback. If you would really like to see this feature supported, I'd suggest you file a radar as a feature request.
This is the answer in objective-c after watchOS 2
[[WKInterfaceDevice currentDevice] playHaptic:WKHapticTypeNotification];
With WatchKit, you have to remember that your code runs on the iPhone and not on the watch. Therefore, AudioServicesPlaySystemSound call from a WatchKit extension would run on the iPhone, not on the watch. It will make the iPhone vibrate.
Related
I am looking for a specific set of function calls into the iOS7 private frameworks / dylibs etc to enable/disable WiFi programmatically on a device running iOS7, or alternatively some other workaround to do the same. If you are tempted to mark this question as a duplicate, please reference a question (an answer would also be nice!) that refers to iOS7. This would have to be a question asked after September, 2013, when iOS7 was released. The private framework class that did this in iOS6, SBWiFiManager, no longer exist in iOS7. I've read through many StackOverflow questions and answers, and grep'd through a lot of framework header files already, so I am aware of some of the ways to go about figuring this out.
* EDIT *
It turns out this is still the correct answer, also has reference to the necessary framework:
How can I enable and disable WiFi connectivity with a jailbroken iOS device?
Why local notification is no supported by OS X 10.9? I know IOS has UILocalNotification Class.
I want to show some notification bellow menu bar which is generated by my program.
Is there any alternate way to do this? Or should I write my own local notification view?
It sounds like you are looking for NSUserNotification functionality, which goes along with the MacOS NSUserNotificationCenter.
I've linked the documentation at Apple to help you out.
As you are learning, many classes and objects supplied in the iOS SDK don't have exact same classes and objects in the MacOS SDK. Anything with "UI" in the framework name is usually meant only for iOS.
I am playing some short sounds on my iPad like so: Play a short sound in iOS
I am using a caf file which I can successfully play from the Finder. Now I went through quite a bit of a hassle trying to achieve the playback of the sound and I am curious what might be the problems which I don't seem to understand:
Option 1: When I create the SystemSoundID and then play it right away I don't hear anything on the device and the simulator.
Option 2: When I create an instance variable for the SystemSoundID and initialize it in viewDidLoad I manage to play sound but only on the iPad, not the Simulator.
Option 3: Instead of using SystemSoundID I can also use AVAudioPlayer to playback a .wav file which then works on both the iPad and the Simulator but here I need to create the AVAudioPlayer in viewDidLoad otherwise I won't get any sound if I do everything in one go.
The best option currently seems to be Option 3 because it works on both the Simulator and the iPad, but because I need to pre-initialize the Player I would need an AVAudioPlayer instance for every different sound that I want to play, which does not seem to be very memory-wise...
Is there something that I am missing and is it possible to play sounds on both platforms using the AudioToolbox framework (Option 1 & Option 2)
I wrote a library to simplify all this. It wraps AVAudioPlayer, and works fine on both the device and simulator.
https://github.com/nicklockwood/SoundManager
The code is fairly straightforward, although I do some semi-clever stuff to initialise the audio player. If you don't want to use the library you can just copy the code.
A word of warning though - the simulator throws some odd exceptions internally whenever you use AVAudioPlayer. They don't affect the app at all, but if you have enabled break-on-exceptions in Xcode then the app will drop into the debugger a few times during startup and you'll have to manually resume, which may freak you out if you're not expecting it.
I want to track four finger touches in my application, but they are cancelled as the iPad uses the four finger swipe to switch applications.
Is there a way to cancel / override this gesture?
I looked into this for a game I worked on and I could not find a way to override it. Even if you found a way, it would probably get you rejected from the app store, since there doesn't seem to be any public API for it.
This be my answer. I'm not sure how you'd go about to actually execute the below as I guess implementions do things differently, but generally it sounds as there is a possibility, because after all these are the words of Apple regarding the multitasking gestures:
"Developers are encouraged to evaluate any existing interactions in
their applications for potential sources of interference. In order to
properly interoperate with multitasking gestures, applications must
properly handle the following methods and notifications:
touchesCancelled:withEvent: (UIResponder) cancelTrackingWithEvent:
(UIControl) applicationDidBecomeActive: and
applicationWillResignActive: (application delegate)
UIApplicationDidBecomeActiveNotification and
UIApplicationWillResignActiveNotification notifications These can be
enabled for development via Xcode so you can update your apps to
interoperate with these new gestures. Test them and give us your
feedback in the Apple Developer Forums."
I really don't think you can because I have watched countless videos on how to override on iPhone/iPod but there are no ones for iPad must be so you can't cheat on games!
I am new to iPhone programming. I am looking for an example or a demo on how to use startMonitoringSignificantLocationChanges method with the CoreLocation Manager.
I am confused by the documentation because, I am not sure if the same delegate method is called as in the case of invoking startUpdatingLocation. (i.e. the delegate locationManager: (CLLocationManager *)manager didUpdateToLocation: (CLLocation *)newLocation fromLocation: (CLLocation *)oldLocation is called)
Any help on this would be appreciated. Also, I am testing it on the simulator by subclassing of CLLocationManager. This subclass provides a simulation of location services when running on the iPhone Simulator. Is there a better way to test this.
I have done a bit of testing with the significant change API. I posted a sample project on GitHub that lets you play with regular and significant location updates.
This question might also shed some light on what happens when you get woken up for a significant change event.
Update
Another thing you should be aware of, there is a bug in CoreLocation in 4.1. Basically if your app is in the background, then it will crash when core location tries to wake you up. It is fixed in 4.2.
There is a great video session on these new iOS 4.0 CoreLocation and MapKit features from WWDC 2010 that should be freely available in iTunes U for all registered iPhone developers.