In my app there should be an alarm when a certain distance is covered. Originally, when the conditions are met, I wanted to move the app to the foreground, show an AlertView and play a sound. Due to answers to my former post I've implemented UILOcaLnotifications and it works fine for playing an AlertSound. Even when my app is in the background and thats great. One issue remains unsolved at this moment. I really want to popup a dialog (AlertView) when the conditions are met.
At this moment the ALert message is shown at the top of the screen (like a received message or missed call) but I want to present the user with a dialog (like in the clock app)
Does anyone knows a solution to this question? Help is most appreciated.
Did you try to assign alertBody and alertAction?
notification.alertBody = #"Some message";
notification.alertAction = #"View"; //title of action button
notification.hasAction = YES; //it YES by default
Related
I'm currently using local notification to indicate incoming call from background mode. That's works fine, but this is what i see, when skype got a call in background mode:
So looks like it possible to show UIAlert from background and anybody can answer me how?
No you can not display an UIAlertView from the background, but you can scheudule a UILocalNotification.
Just set the fireDate property of the UILocalNotification to the current date and it will be displayed directly.
I have implemented one reminder iphone applicaion in which I have used local notification for reminder.
In this application their one functionality alert on/off.
So when user set on then user get notification and if its off then user can get notification.
I have done googling but not got sucess.
Can you give me idea for that is it possible or not.
Thanks in advance
Do you have other notifications in your appln.
If you don't have other notification in your app than,
Do one thing,
When you set OFF
- cancel all the notification
- calculate the time difference of current time & your notification firing time. set this in to some variable.
when you set it ON
- reschedule your Notification based on the time which you have saved earlier.
I am considering that you know how UISwitch works, according to switch position
UILocalNotification *localNotif;
//if switch is on
localNotif = [[UILocalNotification alloc] init];
//else if localNotif is not equal to null then
localNotif = nil;
You can start a timer which continuously check switch position and do the above stuff that depends on your coding.
I'm developing an Alarm App.
When the alarm starts sounding I pop up an UIAlertView in order to offer the user the option to stop it. But when the app is in background the UIAlertView doesn't appears.
How can I do a UIAlert similar to the alert that uses the iOS Alarm?
Thanks!!
You could start reading about this: Apple documentation about notifications. You are probably most likely interested in local notification.
In the app I am working on, I have action sheets and alert views which I would like dismissed when app enters the inactive/ background state.
I am using the UIApplicationWillResignActiveNotification instead of the UIApplicationDidEnterBackgroundNotification as I want the code to be compatible with iOS3.2.
-(void)applicationWillResignActive:(Notification *)notification{
if (self.actionSheet && self.actionSheet.visible){
NSLog(#" actionSheet is Visible");
[self.actionSheet dismissWithClickedButtonIndex:0 animated:NO];
}
}
Testing this in simulator (iphone 3.2, iOS4), with the actionSheet visible, I press the home button, but I do not get the "actionSheet is Visible" message. Yet when I re-open the app and dismiss it again with home button, I get the "actionSheet is Visible" message.
This suggests that the first time the actionSheet's visible property is not being set. Could there be a delay in the property being set? In fact I put a message in the method that displays the actionSheet
[self.actionSheet showInView:self.parentViewController.tabBarController.view];
if (self.actionSheet.Visible) NsLog(#" action Sheet visible");
even here I do not get the message. Where/ when is the visible property set? Am I doing something fundamentally wrong in trying to dismiss the actionSheet? I have seen similar very good and detailed solutions on dismissing alertViews in SO.... but they don't seem to cover this issue. Any help will be much appreciated.
Why would you even need to check if it's visible? In fact, why would you even need to check it against nil? You could just put [self.actionSheet dismissWithClickedButtonIndex:0 animated:NO];, and it should work fine, as if the action sheet exists you will dismiss it, and if it doesn't, you will will just call the method on nil, which does nothing.
I am new to iphone development, i have created sms application using "Text Links(sms:) and i have created the action sheets and the buttons for email, sms. On clicking sms it navigates to the another view(UIView controller) and i wrote a code for SMS.And i faced some problem ,its not removed the view properly, it doesnt goes to the previous webview properly,(Action sheets loaded in webview)
Here my code and explanation,
I have created the custom send button programmatically for sending the sms.
I am getting phone numbers in a textfield and stores it to one string(phone) and i display the article title on the label, it worked dynamically.
now i want to share the article title through sms. and i have one problem, (ie)if i click send button it should go to the previous view(webview) but it display another view.. so i want to go to the previous page properly ,when i clicked the send button.
And i also want to display the address book(Eg,default address book in the device) in my sms view page.Please guide me.
-(void) sendbtnclk
{
self.String = txtfield.text;
NSString *phone = String;
NSString *arttitle = articleTitle;
NSString *sms = [NSString stringWithFormat:#"sms:%# %#",phone,arttitle];
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:sms]];
[self.view removeFromSuperview];
}
thanks,
please help me out.
I think that when you use the openURL: method, the Text app is launched on the phone and thus the current app is dismissed.
Here is the relevant documentation.