iphone - apns alert option (no view option) possible? - iphone

In the official Apple document it says
alert
string or
dictionary
If this property is included, iOS displays a standard alert. You may specify a string as the value of alert or a dictionary as its value. If you specify a string, it becomes the message text of an alert with two buttons: Close and View. If the user taps View, the application is launched.
Alternatively, you can specify a dictionary as the value of alert. See Table 3-2 for descriptions of the keys of this dictionary.
But I wonder if there's any option that I can add to the code to make the push only show "close" button.
Ex of what I have now:
#"{\"aps\":{\"alert\":\"Update OS\"},\"acme1\":\"updateos\",\"acme2\":42}";

I think you can use a dictionary. Have a look at Table 3-2 on the same page, for the key action-loc-key, it says:
If a string is specified, displays an alert with two buttons, whose behavior is described in Table 3-1. However, iOS uses the string as a key to get a localized string in the current localization to use for the right button’s title instead of “View”. If the value is null, the system displays an alert with a single OK button that simply dismisses the alert when tapped. See “Localized Formatted Strings” for more information.
The single OK button is perhaps what you need.

Related

Handling key events in OS X with Swift and Cocoa

I have a very basic OS X that has a few different elements.
A text field, a table view and a file contents view.
I have a single ViewController.
I'd like to be able to intercept specific key events for each of these elements in the storyboard in my ViewController and change the focus between the different elements.
For example, if the cursor is currently in the file contents view, and I hit ESCAPE, I'd like for the focus to be transferred to the text field.
Or, if the focus is currently on the table view and I hit ENTER, that the cursor/focus is moved to the file contents view.
What's the best way to handle this?
I have tried overriding the keyDown method in the ViewController but with things such as autocomplete getting in the way, I'm not having much luck. I have added a print statement to keyDown to check if the function is receiving events, but it's not always fired.
Update
Except for the specific keys that I want to intercept, I want all other key events to behave as normal. For example, typing in the file contents view, or the text field.
I would highly recommend watching the WWDC talk #145 from 2010, Key Event Handling in Cocoa Applications. It gives an overview of the event delivery mechanism, and several ways of handling events:
Make a menu item or button whose keyEquivalent is the escape key.
Override cancelOperation(_:) or complete(_:), which are the two NSResponder methods which can get invoked by default when the escape key is pressed. (There are other methods for the enter/return key.)
Override sendEvent(_:) in NSApplication or NSWindow to intercept all events and bypass the default behavior.

WatchKit How set a string when a certain table is pressed?(Swift)

Im creating a watch app but i have a problem and that is that i want to set a string depending on which table the person pressed in the watch app.
Can anyone help me?????
If I understand correctly you're trying to perform an action when a user taps on a WKInterfaceTable row?
You can achieve this using table:didSelectRowAtIndex: by identifying the corresponding string based on the index and sending an appropriate message to the string.
See the WKInterfaceTable Class Reference

How Remember Me for email id Works

I have created one Login Screen where user enter their mail id.
But i want to insert one functionality where it should list the mail id automatically when user type first character of mail id
There is one way. I don't know how much feasible it is. So the Idea is : You can store somewhere all the email id after log in success. For example in sqlite database. Now, Implement Notification center for "UITextFieldTextDidChangeNotification" and search for the character in database when user start typing in TextField and show UITableview underneath UITextField with match results (which start from entered character).
When user tap on any cell of Tablview hide tableview and take that cell label value in UITextField. That's it. Hope this logic work.
You can save the emaid id in UserDefaults & use it whereever you want

How to enter the text in search bar using UIAutomation?

Could you please help me out in entering the text in search bar using UIAutomation scripts for IPhone Application.
Thanks in advance,
Madhu.
UIASearchBar inherits from UIATextField:
http://developer.apple.com/library/ios/#documentation/ToolsLanguages/Reference/UIASearchBarClassReference/UIASearchBar/UIASearchBar.html#//apple_ref/doc/uid/TP40009913
Try the "setValue" method:
searchBar.setValue("search for this");
Since through tap input method you communicate with the device, you can try user-like type of action: tapping.
To bring up the keyboard you just tap on the text input field:
someTextInputField.tap();
But be aware of the fact that there is no keyboard object instance available for actions if you do not activate the keyboard itself by tapping on any text input field.
Once the keyboard is activated:
var App = UIATarget.localTarget().frontMostApp();
var Keyboard = App.keyboard();
var Keys = Keyboard.keys();
var AltKeys = Keyboard.buttons();
Where AltKeys represent service buttons like Shift, Done, etc.
And Keys represent all other buttons.
P.S. Keep in mind that you have to switch between keyboard tabs to get access to either characters, numbers, special characters.

iPhone numberpad with decimal point

I am writing an iPhone application which requires the user to enter several values that may contain a decimal point (currency values, percentages etc.). The number of decimal places in the values varies. The problem is that the number pad does not contain a key for entering a decimal point.
When I lock my phone, the number pad that comes up to enter a passcode has a custom button to make an emergency call (as seen in the following screenshot):
Numberpad with custom button http://img25.imageshack.us/img25/6426/photoejg.jpg
Does anyone know how to create a number pad with a decimal point button or a custom button (like the emergency call button above)?
Thanks.
There's no Apple-approved way to edit the existing keyboard. If you want them to allow it, file a feature request.
That said, it just so happens that in most applications the keyboard (instance of UIKeyboard) is a separate UIWindow, and you can iterate over the windows in the application and start adding custom subviews that respond to the appropriate touch actions. Find it by iterating over [[UIApplication sharedApplication] windows] and checking to see if the description contains the string UIKeyboard. For more info on this method and some sample code, see this answer.
Another approach is to create your own custom view and build a keyboard from scratch. Be careful if you do this, though, as it requires a lot of manual work, not only in creating the keyboard and getting the touch behavior to match Apple's, but also in any control you add that would bring up the regular keyboard - you'll need to redirect things like becomeFirstResponder to show your own keyboard, rather than Apple's.
Edit: As ZaBlanc pointed out, newer versions of iOS have a way to do this with the inputView and inputAccessoryView properties. See the UIResponder class reference for details.
set UIKeyboardType to UIKeyboardTypeDecimalPad
Available in iOS 4.1 and later.
Create a UIViewController that contains a UIView with a bunch of buttons. Now your keyboard can have whatever you want on it.