Unity3d iOS Unity中的计划本地通知

Unity3d iOS Unity中的计划本地通知,unity3d,uilocalnotification,localnotification,Unity3d,Uilocalnotification,Localnotification,我找不到有关发送预定本地通知的适当教程 我想出了这个,但下面的代码不起作用 void Start() { LocalNotification notif = new LocalNotification(); notif.fireDate = System.DateTime.Now.AddSeconds(5f); notif.alertBody = "Hey"; Notific

我找不到有关发送预定本地通知的适当教程

我想出了这个,但下面的代码不起作用

void Start()

    {
        LocalNotification notif = new LocalNotification();

        notif.fireDate          = System.DateTime.Now.AddSeconds(5f);

        notif.alertBody         = "Hey";    

        NotificationServices.ScheduleLocalNotification(notif);

     }
请帮我做这个

你必须先打电话给“NotificationServices.RegisterForNotifications”。 请参阅=>

您必须首先调用“NotificationServices.RegisterForNotifications”。 请参见=>尝试以下操作:

void ScheduleNotificationForiOSWithMessage (string text, System.DateTime fireDate)
{
    if (Application.platform == RuntimePlatform.IPhonePlayer) {
        LocalNotification notification = new LocalNotification ();
        notification.fireDate = fireDate;
        notification.alertAction = "Alert";
        notification.alertBody = text;
        notification.hasAction = false;
        NotificationServices.ScheduleLocalNotification (notification);

        #if UNITY_IOS
        NotificationServices.RegisterForLocalNotificationTypes (LocalNotificationType.Alert | LocalNotificationType.Badge);
        #endif
    }        
}
试着这样做:

void ScheduleNotificationForiOSWithMessage (string text, System.DateTime fireDate)
{
    if (Application.platform == RuntimePlatform.IPhonePlayer) {
        LocalNotification notification = new LocalNotification ();
        notification.fireDate = fireDate;
        notification.alertAction = "Alert";
        notification.alertBody = text;
        notification.hasAction = false;
        NotificationServices.ScheduleLocalNotification (notification);

        #if UNITY_IOS
        NotificationServices.RegisterForLocalNotificationTypes (LocalNotificationType.Alert | LocalNotificationType.Badge);
        #endif
    }        
}

你好,马吕斯,谢谢你的回复。我只想要预定的本地通知。我不希望任何来自提供商的通知“注册以通过Apple Push服务从提供商接收指定类型的本地和远程通知”。您还必须注册本地通知。名称空间中不存在类型或名称空间名称
iOS
UnityEngine”。是否缺少程序集引用?命名空间中不存在类型或命名空间名称
iOS'
UnityEngine'。是否缺少程序集引用?它在导入命名空间时显示这些错误,如文档中所示。我假设您使用的是Unity4。=>Unity4中Unity5中更改的命名空间使用NotificationServices.RegisterForLocalNotificationTypes代替Hello Marius,感谢您的回复。我只想要预定的本地通知。我不希望任何来自提供商的通知“注册以通过Apple Push服务从提供商接收指定类型的本地和远程通知”。您还必须注册本地通知。名称空间中不存在类型或名称空间名称
iOS
UnityEngine”。是否缺少程序集引用?命名空间中不存在类型或命名空间名称
iOS'
UnityEngine'。是否缺少程序集引用?它在导入命名空间时显示这些错误,如文档中所示。我假设您使用的是Unity4。=>Unity4 use NotificationServices.RegisterForLocalNotificationTypes insteadIt中Unity5中更改的命名空间引发此错误
UnityEngine.iOS.NotificationServices“不包含
RegisterForLocalNotificationTypes”的定义,以及调用此方法时应在第二个参数中传递的内容。感谢您的回复。对于
我应该在第二个参数中传递什么
您可以传递
System.DateTime.Now.AddSeconds(5f)这是通知应该出现的日期。它将引发此错误
UnityEngine.iOS.NotificationServices“不包含
RegisterForLocalNotificationTypes”的定义,以及调用此方法时应在第二个参数中传递的内容。感谢您的回复。对于
我应该在第二个参数中传递什么
您可以传递
System.DateTime.Now.AddSeconds(5f)这是通知应该出现的日期。下面是脚本。这是剧本。