IOS成長之路-推送(本地推送) – iPhone手機開發技術文章 iPhone軟體開發教學課程

1、打開本地推送並設置屬性

 

 

[cpp] 

NSString *str = @"本地推送的信息";  

    UIApplication *app = [UIApplication sharedApplication];  

    UILocalNotification *notification = [[UILocalNotification alloc]init];//初始化本地推送   

    notification.soundName = UILocalNotificationDefaultSoundName;//設置聲音   

    notification.alertBody = str;//設置推送的消息   

    [app scheduleLocalNotification:notification];//實現本地推送的關鍵步驟,   

    [notification release];  

    [str release];  

 

NSString *str = @"本地推送的信息";

    UIApplication *app = [UIApplication sharedApplication];

    UILocalNotification *notification = [[UILocalNotification alloc]init];//初始化本地推送

    notification.soundName = UILocalNotificationDefaultSoundName;//設置聲音

    notification.alertBody = str;//設置推送的消息

    [app scheduleLocalNotification:notification];//實現本地推送的關鍵步驟,

    [notification release];

    [str release];通過上面的方法可以實現推送的效果

 

 

2、本地推送的接受方法 

 

 

[cpp]

– (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification  

 

– (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification

 

You May Also Like