Obl*_*ey3 1 notifications alert push-notification ios xamarin
我正在使用Xamarin和iOS,但是在通知方面我遇到了很多麻烦.我可以创建一个发送到通知中心的本地推送通知,但没有声音或指示通知实际到达.如何使通知成为警报通知,以便在进入通知中心之前显示在屏幕上?
这是我正在生成通知的代码:
//create notification
var notification = new UILocalNotification ();
notification.AlertAction = "Open App";
notification.AlertTitle = "App";
notification.AlertBody = "There has been activity in the app";
notification.SoundName = UILocalNotification.DefaultSoundName;
//display notification
UIApplication.SharedApplication.ScheduleLocalNotification (notification);
Run Code Online (Sandbox Code Playgroud)
编辑:问题不仅仅是声音,而是没有收到警报的反馈,它只是静默地出现在通知中心.我也要求使用此代码的权限:
var settings = UIUserNotificationSettings.GetSettingsForTypes(
UIUserNotificationType.Alert
| UIUserNotificationType.Badge
| UIUserNotificationType.Sound,
new NSSet());
UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
UIApplication.SharedApplication.RegisterForRemoteNotifications();
Run Code Online (Sandbox Code Playgroud)