我想在游戏中做条幅通知。
不警觉
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
if (application.applicationState == UIApplicationStateActive ) {
NSString *message = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.userInfo = userInfo;
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.alertBody = message;
localNotification.fireDate = [NSDate date];
[[UIApplication sharedApplication] presentLocalNotificationNow:localNotification];
}
}UILocalNotification在游戏中不工作
如何操作横幅??有什么问题??
发布于 2014-07-15 09:10:54
试着像这样
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
NSString *message = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];
localNotification.applicationIconBadgeNumber =0;
localNotification.alertBody =message;
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:0];
localNotification.timeZone = [NSTimeZone defaultTimeZone];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];确保在iPhone->Settings-> notification中启用了通知,如果应用程序当前处于打开状态,本地通知(以及推送通知)将不会显示。
发布于 2014-07-15 09:00:55
开发人员无法设置通知警报类型。只有用户可以在iOS的设置菜单中设置。
https://stackoverflow.com/questions/24753892
复制相似问题