didReceiveRemoteNotification and Banner Notification



我想在游戏过程中做横幅通知。

没有警报

- (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在游戏过程中不工作

如何操作横幅??什么问题? ?

试一下

 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->设置->通知中启用了通知,如果您的应用程序当前处于打开状态,则不会显示本地通知(以及推送通知)。

通知警报类型不能由开发人员设置。只有用户可以在iOS的设置菜单中设置。

相关内容

  • 没有找到相关文章

最新更新