0
我有xamarin表单支持通知的应用程序,我已经在android中使用广播接收器完成了它,现在我必须在ios中做通知! ,我的服务取决于API REST,所以我希望每隔60秒ios应用程序运行HTTP请求并获取数据,然后将其显示为通知,我搜索了很多天但我无法达到我的方法? 如果这是不可能的我可以使用nuget或类似的东西在ios项目中“在xamarin形式的解决方案”或不?在http请求中创建xamarin ios的本地通知
content = new UNMutableNotificationContent();
content.Title = "Notification Title";
content.Subtitle = "Notification Subtitle";
content.Body = "This is the message body of the notification.";
content.Badge = 1;
content.CategoryIdentifier = "message";
var trigger = UNTimeIntervalNotificationTrigger.CreateTrigger(60, true);
var requestID = "sampleRequest";
var request = UNNotificationRequest.FromIdentifier(requestID, content, trigger);
UNUserNotificationCenter.Current.AddNotificationRequest(request, (err) =>
{
if (err != null)
{
// Do something with error...
}
});
因此,我可以打电话给我的http请求从60后自动从服务器导入数据像我一样或5像你一样? –
60(或5)与您从服务器导入数据的频率无关。延迟显示通知需要多长时间。您应该使用计时器从共享(PCL)代码调用服务器。一旦你有数据调用平台特定的代码来触发通知。 –
在android平台有一个服务,运行代码在后台没有计时器,我不知道是否有这样的事情在ios中,无论如何,我认为我不能解释第二个问题,或者我错过了TI的逻辑:),谢谢史蒂夫先生 –