2013-07-29 2 views
2

J'ai une application où je dois utiliser l'affichage des alertes et je sais qu'il n'est pas possible de le définir, de sorte que la notification est disponible en mode d'affichage alerte. Comment puis-je le configurer de sorte que si l'utilisateur appuie sur ce que je peux, ils peuvent recevoir des notifications locales, il sera automatiquement mis en alerte.Comment définir la vue d'alerte par défaut

+0

*** J'ai une application où vous devez utiliser la vue d'alerte et je sais que ce n'est pas possible de le définir de cette façon ***. que voulez-vous dire ?? –

+0

S'il vous plaît être précis, ce que vous voulez ????? – SachinVsSachin

+0

Désolé, mon application nécessite qu'une notification loal leur vient en vue d'alerte. Alors, comment puis-je le définir de cette façon. –

Répondre

1

vous pouvez simplement UILocalNotification avec ma méthode ci-dessous personnalisé ..

- (void) scheduleAlarm:(NSString *)PaymentTitle FireDate:(NSDate *)tempFireDate { 

    NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar]; 


    NSDate *pickerDate = tempFireDate; //Set yourDate here 

    // Break the date up into components 
    NSDateComponents *dateComponents = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) 
    fromDate:pickerDate]; 
    NSDateComponents *timeComponents = [calendar components:(NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit) 
    fromDate:pickerDate]; 
    // Set up the fire time 
    NSDateComponents *dateComps = [[NSDateComponents alloc] init]; 
    [dateComps setDay:[dateComponents day]]; 
    [dateComps setMonth:[dateComponents month]]; 
    [dateComps setYear:[dateComponents year]]; 
    [dateComps setHour:[timeComponents hour]]; 
// Notification will fire in one minute 
    [dateComps setMinute:[timeComponents minute]]; 
[dateComps setSecond:[timeComponents second]]; 
    NSDate *itemDate = [calendar dateFromComponents:dateComps]; 
// [dateComps release];//comment it if use ARC 

    UILocalNotification *localNotif = [[UILocalNotification alloc] init]; 
    if (localNotif == nil) 
     return; 
    localNotif.fireDate = itemDate; 
    localNotif.timeZone = [NSTimeZone defaultTimeZone]; 

// Notification details 
    localNotif.alertBody [email protected]"Write your Message"; 
// Set the action button 
    localNotif.alertAction = @"View"; 

    localNotif.soundName = UILocalNotificationDefaultSoundName; 
    localNotif.applicationIconBadgeNumber = 1; 

// Specify custom data for the notification 
    NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"iClientManagement" forKey:@"App"]; 
    localNotif.userInfo = infoDict; 

// Schedule the notification 
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotif]; 
// [localNotif release];//cxomment it if use ARC 
} 

Voir Ma cette méthode sur My Blog

Voir aussi une autre démonstration tout de ce lien ci-dessous pour l'affichage UILocalNotifications

iphone-programming-tutorial-local-notifications

+0

C'est mieux un commentaire –

+0

@ LithuT.V je sais mec que pour un commentaire de ligne est meilleur mais je veux poster ma méthode personnalisée pour 'UILocalNotification' donc je posterai la réponse .. Thanx: –

+0

Maintenant c'est une réponse :) –

Questions connexes