Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/456.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 带有$InstallationId标记的通知中心推送问题_Javascript_Azure Mobile Services_Azure Notificationhub - Fatal编程技术网

Javascript 带有$InstallationId标记的通知中心推送问题

Javascript 带有$InstallationId标记的通知中心推送问题,javascript,azure-mobile-services,azure-notificationhub,Javascript,Azure Mobile Services,Azure Notificationhub,我正在使用通过GCM注册和发送推送通知。我使用push.patch安装注册通知客户端,如下所示: var updateOperation = [{ 'op': 'replace', 'Path': '/tags', 'Value': tags.join() }]; push.patchInstallation(installationId, updateOperation, function (error, res) { /*...*/ }; 从通知中心的注册情况来看

我正在使用通过GCM注册和发送推送通知。我使用push.patch安装注册通知客户端,如下所示:

var updateOperation = [{
    'op': 'replace',
    'Path': '/tags',
    'Value': tags.join()
}];

push.patchInstallation(installationId, updateOperation, function (error, res) { /*...*/ };
从通知中心的注册情况来看,它工作得很好

<GcmRegistrationDescription xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <ETag>13</ETag>
    <ExpirationTime>9999-12-31T23:59:59.9999999Z</ExpirationTime>
    <RegistrationId>1234568266548022282-123456473823493176-1</RegistrationId>
    <Tags>$InstallationId:{SOME_GUID},location_1,location_2,location_3,userId:myaccount@domain.com</Tags>
    <GcmRegistrationId>SOME_ID</GcmRegistrationId>
</GcmRegistrationDescription>
它不会将$InstallationId注入标记,而是创建两个具有相同GCMRRegistrationID但具有不同标记的注册,其中一个具有$InstallationId

<RegistrationId>REGID1</RegistrationId>
<Tags>$InstallationId:{SOMEGUID},_UserId:sid:SOMESID</Tags>
<GcmRegistrationId>GCMREGID</GcmRegistrationId>
REGID1
$InstallationId:{SOMEGUID},_UserId:sid:SOMESID
GCMREGID
另一个只有我在createOrUpdateNativeRegistration中定义的标记

REGID2
位置1、位置2、位置3
GCMREGID

有了它,我可以使用位置标签向测试设备发送推送消息(也可以使用$InstallationId向特定设备发送推送消息),这样两种注册都可以工作。我不知道为什么它会创建两个注册,因为我在任何时候都没有任何对notificationHubService.createRegistrationId的调用,只有对createOrUpdateNativeRegistration的一个调用。

这是一个有效的场景。您应该能够使用位置标签推送通知。您是否可以尝试在portal.azure.com中使用“测试发送”来验证是否选择了用于推送通知的设备?

这是一个有效的方案。您应该能够使用位置标签推送通知。您是否可以尝试在portal.azure.com中进行“测试发送”以验证是否选择了用于推送通知的设备?

根据您的描述,您正在使用安装型号,并且系统标签
$InstallationId:[InstallationId]
会自动添加到您的安装中,您可以发送到此标记以定位特定设备

从代码中,您正在使用更新注册上的标记。您通过
tags.join()
将标签替换为单个字符串标签

要为您的安装更换多个标记,您需要指定
updateOperation
,如下所示:

var更新操作=[{
“op”:“replace”,
“路径”:“/tags”,
“值”:标记//标记数组。
}];

此外,您可以尝试阅读您的安装并检查标记以缩小此问题。

根据您的描述,您使用的是安装型号,系统标记
$InstallationId:[InstallationId]
会自动添加到您的安装中,您可以发送到此标记以定位特定设备

从代码中,您正在使用更新注册上的标记。您通过
tags.join()
将标签替换为单个字符串标签

要为您的安装更换多个标记,您需要指定
updateOperation
,如下所示:

var更新操作=[{
“op”:“replace”,
“路径”:“/tags”,
“值”:标记//标记数组。
}];

此外,您可以尝试阅读安装并检查标记以缩小此问题的范围。

我建议您遵循此问题的疑难解答。抱歉,那篇文章没有讨论此问题。我建议您遵循此问题的疑难解答。抱歉,那篇文章没有讨论此问题。我相信这不会改变任何事情,不管我怎么做,最终的结果是包含逗号分隔的标记列表(如您在OP中所看到的)。如果第一个标记是$InstallationId:[InstallationId],则其他标记都不起作用。如果我使用注册模型来设置标记,使其不包含$InstallationId,那么所有标记都非常有效!从您的测试来看,在使用安装模型时,它似乎只能发送带有标记的push
$InstallationId:{SOME_GUID}
。您是否尝试通过代码检索安装并检查有效标记?是的,获取安装表明标记有效,即$InstallationId:{SOME_GUID},location_1,location_2,location_3,userId:myaccount@domain.com,当然除了自动注入的$InstallationId之外,因为它包含$,这在标记中不是一个有效的字符。我相信这不会改变任何事情,因为无论我如何做,最终的结果是包含逗号分隔的标记列表(如您在OP中所看到的)。如果第一个标记是$InstallationId:[InstallationId],则其他标记都不起作用。如果我使用注册模型来设置标记,使其不包含$InstallationId,那么所有标记都非常有效!从您的测试来看,在使用安装模型时,它似乎只能发送带有标记的push
$InstallationId:{SOME_GUID}
。您是否尝试通过代码检索安装并检查有效标记?是的,获取安装表明标记有效,即$InstallationId:{SOME_GUID},location_1,location_2,location_3,userId:myaccount@domain.com,当然除了自动注入的$InstallationId之外,因为它包含$,这在标签中不是一个有效的字符。谢谢你确认它应该工作。但是,无论我使用Postman通过REST发送通知,还是使用Azure Test send,如果第一个标记是$InstallationId,它都不会找到标记的注册。Azure Test Send说:“消息已成功发送,但没有匹配的目标。”感谢您确认它应该可以工作。但是,无论我使用Postman通过REST发送通知,还是使用Azure Test send,如果第一个标记是$InstallationId,它都不会找到标记的注册。Azure测试发送说:“消息已成功发送,但没有匹配的目标。”
<RegistrationId>REGID1</RegistrationId>
<Tags>$InstallationId:{SOMEGUID},_UserId:sid:SOMESID</Tags>
<GcmRegistrationId>GCMREGID</GcmRegistrationId>
<RegistrationId>REGID2</RegistrationId>
<Tags>location_1,location_2,location_3</Tags>
<GcmRegistrationId>GCMREGID</GcmRegistrationId>