Question

I have implemented UIlocalNotification method using the link

Adding Local Notifications With iOS 4

in my app my requirement is that

in notification alert we need to have only "Show me" button which opens the app by default,

we need to force the user to open the app when notification , So there must no close button in the notification alert.

only one button that too Show me must opent the app

how?

Was it helpful?

Solution

If you do not want to show the alert action button you can disable it by setting the hasAction property to NO.
Note that without the action button there is no option for the user to launch the application from the alert.
(If you do not want to see the alert at all you should set alertBody to nil.)

EDIT:

  • You can not remove cancel button.
  • You have only option to remove action button not cancel button and As it is defined in implementation file of UILocalNotification so u can not override it.

OTHER TIPS

You can't remove the cancel button.

Few more things are there:

  • If the phone is locked means the user can't see any buttons(a swipe button appears to perform ur showme function).
  • If the user changed the settings for notification to other than alert type, the user can't even see the UIAlertView.

Make sure your view conforms to UIAlertViewDelegate protocol:

@interface YourViewController : UIViewController <UIAlertViewDelegate> 

When you want the alert to show, do this:

 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Message" delegate:self cancelButtonTitle:@"Show me" otherButtonTitles:nil];

If you want to do something when the button is clicked, implement this

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex;{
// the user clicked OK
if (buttonIndex == 0)
{
    //do something here...
}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top