小编Meg*_*ley的帖子

Xamarin Forms Entry调用Completed事件

我目前正在Xamarin Forms中的登录和注册页面上工作,在将键盘的完成按钮更改为下一个并继续上一个后,我不再在Android上接收完成事件(在iOS上正常工作).在自定义渲染器中,我可以捕获Control.EditorAction事件,该事件现在与Completed事件的行为相同,但我似乎无法在条目本身上调用Completed事件.

在EntryRenderer中

Control.EditorAction += (object sender, TextView.EditorActionEventArgsargs) =>
{
    if (entryExt.ReturnKeyType != ReturnKeyTypes.Next)
        entryExt.Unfocus();

    // Call all the methods attached to base_entry event handler Completed
    entryExt.InvokeCompleted();
};
Run Code Online (Sandbox Code Playgroud)

在EntryExt中(直接扩展Entry)

public void InvokeCompleted()
{
    Completed?.Invoke(this, null);
}
Run Code Online (Sandbox Code Playgroud)

但由于错误,无法调用Completed事件

Error CS0070: The event `Xamarin.Forms.Entry.Completed' can only appear on the left hand side of += or -= when used outside of the type `Xamarin.Forms.Entry'
Run Code Online (Sandbox Code Playgroud)

有没有办法调用Completed事件?我宁愿在我的视图中没有单独的事件处理程序.

c# android xamarin xamarin.forms

7
推荐指数
1
解决办法
6058
查看次数

Android Xamarin使推送通知不创建新活动但使用当前活动

我们目前正在开发适用于iOS,Android和WP8的Xamarin Forms移动应用程序,目前我正在开发Android的通知部分.

现在,我能够收到通知并将其显示给用户,当他们点击通知时,它会将他们带到应用程序,但它不会像我们希望它一样工作.它不是继续在同一个Activity中,而是启动一个全新的活动,它会丢失实际应用程序的整个上下文.

在我们的推送通知接收器上,我们重写了OnMessage方法,只要有来自我们服务器的内容就会调用它,在这里我们有以下代码

protected override void OnMessage(Context context, Intent intent)
    {
        string message = string.Empty;

        // Extract the push notification message from the intent.
        if (intent.Extras.ContainsKey("message"))
        {
            message = intent.Extras.Get("message").ToString();
            var title = "Notification:";

            // Create a notification manager to send the notification.
            var notificationManager = GetSystemService(Context.NotificationService) as NotificationManager;

            Intent resultIntent = new Intent(context, typeof(MainActivity));
            resultIntent.PutExtras(intent.Extras);

            PendingIntent contentIntent = PendingIntent.GetActivity(
                                              context,
                                              0,
                                              new Intent(),
                                              PendingIntentFlags.UpdateCurrent
                                          );


            // Create the notification using the builder.
            var builder = new Notification.Builder(context);
            builder.SetAutoCancel(true); …
Run Code Online (Sandbox Code Playgroud)

notifications android ios xamarin

5
推荐指数
1
解决办法
2477
查看次数

NodeJS crypto.createHmac SHA256 无法正常工作

我目前正在尝试实现我们正在使用的库的身份验证部分,但我偶然发现了一个奇怪的数据签名问题,NodeJS 中的 crypto.createHmac 的输出大约是 hash_hmac 的一半在 PHP 中,这是 PHP 和 NodeJS 之间唯一不同的数据部分(我们需要在这里使用 NodeJS)

用于在 NodeJS 中创建签名的确切代码是,

authorization["oauth_signature"] = crypto.createHmac('SHA256', process.env.SECRET).update(toSign).digest('base64');
Run Code Online (Sandbox Code Playgroud)

对于 PHP,它是

$authorization["oauth_signature"] = base64_encode(hash_hmac("SHA256", $signatureString . $signingKey, $secret));
Run Code Online (Sandbox Code Playgroud)

但是 NodeJS 版本的输出是

7LkQP+qKR1gSdPq/AgH/3No3ps7EtZXnqwjivMixvM8=
Run Code Online (Sandbox Code Playgroud)

对于 PHP,它是

NmQ0MWIzYmJiMjI2YzFlMDhiYzY3NzVmMWY0MzEwNDlhNDU3NDI0ZGJlMzU3NjJhYmMwYjgwYzZjMDE4NDM4OA==
Run Code Online (Sandbox Code Playgroud)

其中有超过两倍的数据

我是否必须为 NodeJS 版本使用不同的库,而不是在一个库中构建?顺便说一句,我们在 Microsoft Azure 上托管我们的 NodeJS 后端,不确定这是否相关,但至少值得一提。

编辑:

我发现了这个问题,PHP中的hash_hmac自动将其数据导出为十六进制数据,crypto.createHmac将其数据导出为我直接转换为base64的原始二进制数据,我需要做的就是首先将数据导出为十六进制然后转换到base64。

php sha256 azure hmac node.js

2
推荐指数
1
解决办法
6126
查看次数

标签 统计

android ×2

xamarin ×2

azure ×1

c# ×1

hmac ×1

ios ×1

node.js ×1

notifications ×1

php ×1

sha256 ×1

xamarin.forms ×1