Ok
On first run I ask for the mobile phone number in an alertview. This is using - (void)textFieldDidEndEditing:(UITextField *)textField to validate the phone number.
Now I also have push notifications.
The trouble is when the app is first installed the alertview shows and the keyboard shows but the "Do you want to enable push notifications" alert also shows. So whats the problem? Well the alert shows then over the alert the push notification shows blocking the input box. Then the keyboard shows blocking the "Yes/No" buttons of the push notification.
Therefor I cannot dismiss or answer either alert! So my first thought is to comment out [passwordField becomeFirstResponder]; for the phone number alert and the keyboard can be dismissed but then my validation never gets called. :(
Any suggestions will be appreciated.
You have to delay your register for push notifications code until after your UI is done.
Related
In running my program, a basic chat app which i'm writing to learn ios, i noticed different results with:
[self._inputBox resignFirstResponder];
vs
[sender resignFirstResponder];
i have this ibaction:
- (IBAction)_sendText:(id)sender
which is called on hitting the send button. its also called on enter as that ibaction calls the same ibaction as the send button.
Now on the iphone which i just supported tonight ( it's a one view now i have both a view on my ipad storyboard and my ipod and wired the ipad actions to the ipod storyboard tonight) for clicking the send button which is wired to this ibaction, self.inputBox calling resignFirstResponder works but sender resignFirstResponder did not work. I have a friend who is testing and he was the one who found it didn't work on his ipod. I have only run it in the simulator and both worked there.
Mike
If a "Send" button is connected to your _sendText: action and you click that button, then the button is the sender and not your text input field, therefore [sender resignFirstResponder] will not have the desired effect.
my app is almost finished and since is for airline pilots I would like to add a disclamer (like an alert view...but more like a scroll view) that pop up as soon as they start the app and if they don't press ok I want to exit from the app. Any advice would be really appreciated.
thanks
Just use a UIAlertView — if you put a lot of text in it, it automatically scrolls.
If the user presses the "No" button, you need to just disable the app rather than exit — apps aren't allowed to exit unless the user presses the home button. You could pop up a modal view controller (with no way of dismissing it) with a message saying that the app cannot be used until the disclaimer is read and accepted.
Please help me understanding this:
When home button is pressed and iPhone application goes in the background and a Push Notification is received. There is an alert being displayed which contains the message for that notification with "View" button on it. Where this alert is coming from -- IOS generating it?
In my code I wrote code for showing alert when notification comes in inside my
- (void)application:(UIApplication *)iApplication didReceiveRemoteNotification:(NSDictionary *)iUserInfo {
method. And on this alert action I am showing my view controller. Now, I am ending up showing two alerts -- One which is coming from IOS (I believe) and on tap of view is taking me to last visited page of my app and Second which I created and on tap of View is taking me to desired page.
Please help understanding this.
If I understand you correctly, you get two AlertViews instead of one if you click on View. Then you should check whether the application is active or not. Have a look at the UIApplication Class Reference
UIApplication Class Reference #applicationState
- (void)application:(UIApplication *)iApplication didReceiveRemoteNotification:(NSDictionary *)iUserInfo {
if([application applicationState] == UIApplicationStateActive) {
//show alert
}
}
Oliver Drobnik wrote a very detailed examination of the possible message flows when dealing with notifications and app state. The short version - if your apps not frontmost, the OS displays a notification and may launch your app in response to user actions; if your app is frontmost, you're responsible for everything, be it displaying an alert or some other processing.
http://www.drobnik.com/touch/2010/07/understanding-ios-4-backgrounding-and-delegate-messaging/
I have a situation say I have to print Notification viewed when local notification is viewed and Notification closed when close button of notification is clicked basically I want to know if we have an event/method which is fired once the notification's cancel button is pressed.
If this is not possible then do we have a method which got fired when the notification is displayed or pushed?
Please shed some light on this.
Your app isn't running, so there is no way to interact with the OS.
The OS will display the localnotification, thus there is no way to either check if the notification is displayed or the cancel button is pressed.
What happens if I send a push notification to the iPhone and it's during a call, or during incoming call?
would it popup on the screen and show the notification to the user?
Yes, it gets displayed on screen and the user will need to close the notification before they can click the "End Call" button. It's a little distracting, but does ensure that the notification has a chance at being viewed. After all, it might be an important notification.