Tag: xamarin

FCM – 重新调试应用程序后发送消息时出现Android Xamarin NotRegistered错误

我正在Xamarin Android中开发一个应用程序,用于通知我正在使用FCM预发布包: https : //www.nuget.org/packages/Xamarin.Firebase.Messaging/ 现在一切正常,如果我清理App数据,会触发OnTokenRefresh事件并生成新令牌 – 当我在此令牌上发送新通知时,设备在OnMessageReceived()发送和接收通知 – 问题是当我对代码进行更改并再次运行应用程序时,如果我使用旧令牌,则在发送通知时会收到NotRegistered错误,但如果我去清理App Data,则会触发OnTokenRefresh()生成新令牌 – 新令牌有效。 类似的问题在这里,但这是GCM(我使用的是FCM): Google云消息“未注册”失败并取消订阅最佳做法? https://stackoverflow.com/a/36856867/1910735 https://forums.xamarin.com/discussion/65205/google-cloud-messaging-issues#latest 我的FCMInstanceIdService [Service, IntentFilter(new[] { “com.google.firebase.INSTANCE_ID_EVENT” })] public class FCMInstanceIdService : FirebaseInstanceIdService { private string Tag = “FCMInstanceIdService”; public override void OnTokenRefresh() { var fcmDeviceId = FirebaseInstanceId.Instance.Token; if (Settings.DeviceId != fcmDeviceId) { var oldDeviceId = Settings.DeviceId; Settings.DeviceId = fcmDeviceId; […]

Xamarin表单更新listView itemSource

好吧我有一个ListView对象,它有一个List作为ItemSource ,我想在对象列表发生变化时刷新ItemSource 。 ListView有一个个性化的ItemTemplate现在我已经这样做了: public NearMe () { list=jM.ReadData (); listView.ItemsSource = list; listView.ItemTemplate = new DataTemplate(typeof(FilialeCell)); searchBar = new SearchBar { Placeholder=”Search” }; searchBar.TextChanged += (sender, e) => { TextChanged(searchBar.Text); }; var stack = new StackLayout { Spacing = 0 }; stack.Children.Add (searchBar); stack.Children.Add (listView); Content = stack; } public void TextChanged(String text){ //DOSOMETHING […]

在Xamarin中安装android v4支持库后出现错误

即使在从Xamarin Component Store安装v4支持库后,我也会收到此错误。我尝试使用Google搜索这些问题,但在开发Android应用时,我总是在Xamarin Studio中遇到同样的错误

Xamarin与Prism MasterDetail导航一起使用

我已经开始使用Prism和Xamarin.Forms在Xamarin Studio上构建应用程序。 我的问题是,我似乎无法找到代码片段作为应用内部MasterDetail导航的示例。 每次我导航到一个页面时,它只会在上一个主视图的顶部呈现一个新视图。 是否有某个示例或关于如何使用可切换视图的说明,以便在xamarin上使用棱镜实现主/细节导航? 我已经为Windows窗体应用程序找到了一些棱镜示例,但没有特定于xamarin窗体。 提前谢谢你,对于这个普遍的问题感到抱歉。

Xamarin表格中的触发活动指标

我的Xamarin.Forms应用程序上有一个图标,当点击它时,我想将其更改为活动指示器。 看起来我应该使用Trigger ,事件触发器看起来不错,但是当我的图像在XAML中声明时,我不确定它是如何组合在一起的? 目前,我在stacklayout底部的XAML中有这个: 单击它时,我想在一段时间内显示此信息,然后触发一些C#function: 我不确定是否最好在XAML中使用触发器配置它,或者我是否可以在XAML中拥有占位符类型项,然后在C#中拥有所有定义?

如何在Xamarin中找到当前的UIViewController

我正在使用Facebook Auth SDK ,以及Xamarin Forms C# 示例 。 但是,Facebook SDK已经对该方法进行了折旧,并将其替换为将一个fromViewController变量添加到构造函数中的方法。 我对Xamarin中的ViewControllers概念并不是特别熟悉,或者确实使用这个代码,因为它来自一个示例,所以有没有办法测量当前的ViewController? 我见过几个.net示例,例如NSArray *viewContrlls=[[self navigationController] viewControllers];[viewContrlls lastObject]; 但是,这种方法似乎不适用于Xamarin,因为self不包含navigationControllers的定义。 或者,有没有什么方法可以使用示例代码轻松计算出当前ViewController的哪个变量?

使用Httpclient信任自签名证书

我正在尝试通过自签名证书发出失败的Web请求: Client = new HttpClient(); HttpResponseMessage Response = await Client.GetAsync(Uri)//defined elsewhere 这会引发信任失败exception。 我按照这里建议使用httpclienthandler再次尝试使用HttpClient允许不受信任的SSL证书 : var handler = new HttpClientHandler(); handler.ServerCertificateCustomValidationCallback = ( HttpRequestMessage message, X509Certificate2 cert, X509Chain chain, SslPolicyErrors errors ) =>{return true; };//remove if this makes it to production Client = new HttpClient(handler); 抛出一个未实现exception的系统。 有没有其他方法可以信任自签名证书? 我甚至在提出请求的机器上安装了证书,但没有运气。

无法激活Xamarin Unhanded ERROR – Visual Studio 2015更新2

我尝试在Visual Studo 2015 Update 2上激活xamarin帐户,错误是: System.FormatException: One of the identified items was in an invalid format. at Xamarin.Components.Ide.Activation.ActivationService.GetErrorWorkflow(LicenseSyncResult[] results, Boolean ignoreSyncErrors) at Xamarin.Components.Ide.Activation.ActivationService.d__100.MoveNext() at Xamarin.Components.Ide.Activation.ActivationDialog.DisplayWorkflowStep(ActivationWorkflowStep step) at Xamarin.Components.Ide.Activation.ActivationDialog.c__DisplayClass11.b__12(Task t)

Nunit ExpectedException正常工作吗?

在设置一些命令行脚本来测试我正在处理的项目的NUnit测试套件时,我开始遇到问题。 我注意到在Visual Studio或Xamarin中运行测试时结果是我的预期,但是当使用nunit-console (mac v2.4.8 )从命令行运行时,它不会使某些测试失败。 在控制台中失败的所有失败的测试都使用[ExpectedException]属性(两者都有类型和一般)。 更改为使用Assert.Throws它在IDE和命令行中都能正常工作。 这是Nunit或我拥有的特定版本/平台的错误吗?

如何将ListView按钮的绑定上下文设置为Xamarin Forms中父级的绑定上下文

基本上,我有一个带有DataTemplate选择器的ListView,它使用基于ListView项的特定DataTemplate。 现在,在DataTemplate中 – 我有一个带有命令的按钮,应该在Parent(或ListView)本身的ViewModel上绑定。 请注意,我只想绑定按钮的Command属性,因为Text和其他属性需要绑定到按钮的当前绑定Context。 DataTemplate的BindingContext是ListView Item bindingContext(在本例中为Message Model),但我希望能够将数据模板中的特定按钮仅绑定到父listView的viewmodel。 我怎么做?