我想在游戏过程中做横幅通知。
不警告
- (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在游戏过程中无效
如何操作横幅?什么问题??
答案 0 :(得分:0)
开发人员无法设置通知警报类型。只有用户可以在iOS的设置菜单中进行设置。
答案 1 :(得分:0)
试试这个
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中启用了通知 - >设置 - >通知, 如果您的应用程序当前处于打开状态,则不会显示本地通知(以及推送通知)。