zee*_*ikh 1 iphone xcode objective-c statusbar ios
在我的应用程序中,我使用一些网络连接获取数据
我想在iPhone中的通知栏(状态栏)中显示该数据
所以当我向下拖动时,如何添加我在iPhone状态栏中可以看到的数据
我搜索了许多教程,但我没有找到任何好的,请帮助我
请告诉我一些想法,我可以在通知或任何好的教程中管理我的数据
请建议任何好的教程,以便我可以在通知栏中管理我的动态数据
谢谢
获取数据后:
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
localNotif.fireDate = date; // date after 10 sec from now
localNotif.timeZone = [NSTimeZone defaultTimeZone];
// Notification details
localNotif.alertBody = text; // text of you that you have fetched
// Set the action button
localNotif.alertAction = @"View";
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.applicationIconBadgeNumber = 1;
// Specify custom data for the notification
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"someValue" forKey:@"someKey"];
localNotif.userInfo = infoDict;
// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
Run Code Online (Sandbox Code Playgroud)
处理通知的onclick:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
[window addSubview:viewController.view];
[window makeKeyAndVisible];
application.applicationIconBadgeNumber = 0;
// Handle launching from a notification
UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif) {
NSLog(@"Recieved Notification %@",localNotif);
}
return YES;
}
- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {
// Handle the notificaton when the app is running
NSLog(@"Recieved Notification %@",notif);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4436 次 |
| 最近记录: |