有没有办法在使用“警报"时阻止解析拦截我的通知?钥匙? [英] Is there a way to keep parse from intercepting my notifications when using "alert" key?

查看:59
本文介绍了有没有办法在使用“警报"时阻止解析拦截我的通知?钥匙?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 parse 来发送和处理 android 和 ios 的通知.我不想处理有关为 ios 或 android 以不同方式发送通知的部分,因为确定用户使用的设备或操作系统并不容易.用户可以同时拥有并在两个生态系统中使用该应用程序,因此我想发送适用于 android 和 ios 的通知.

I am using parse to send and handle notifications for android and ios. I don't want to handle the part about sending the notification differently for either ios or android because it is not easy to determine what device or operating system a user is using. A user could have both and use the app on both ecosystems, so I want to sent out notifications which work on both android and ios.

到目前为止,我已经成功了,两种设备类型都会收到通知.android 和 parse 的问题是,该 parse 非常顽固.当使用警报"或标题"键时,解析会在我的 BroadcastReceiver 处理它之前显示通知.

So far I have succeeded, both device types get a notification. The thing with android and parse is, that parse is pretty stubborn. When the "alert" or the "title" key is used, then parse displays the notification before my BroadcastReceiver gets to handle it.

我做了一些研究,据我所知,将密钥从警报"更改为其他内容就可以解决问题.我的问题是,无论怎样才能让它在 iphone 上正常工作,我都必须使用警报".还有什么我可以做的,并且在不解析拦截通知的情况下保持我的 BroadcastReceiver 吗?

I did some research and to my understanding, changing the key from "alert" to something else does the trick. My problem is, I have to use "alert" no matter what to keep it working on iphones. Is there something else I could do and keep my BroadcastReceiver without parse intercepting the notification?

有没有办法改变警报"键并在 ios/iphones 下仍然保持功能?

Is there a way to change the "alert" key and still maintain functionality under ios/iphones?

提前致谢.

推荐答案

我能够通过在 CloudCode for iOS 和 Android 中对 Parse.Push.send() 进行两次不同的调用来解决这个问题.

I was able to address this issue by making two different calls to Parse.Push.send() in CloudCode for iOS and Android.

// iOS
query.equals("deviceType", "ios");
data = {"alert":"some alert", "data":{other params here}};
Parse.Push.send({
    where: query,
    data: data
}

// Android
query.equals("deviceType", "android");
data = {"data":{"alert":"some alert", other params here}, "action":"com.mycompany.customBroadcastReceiver_actionId"};
Parse.Push.send({
    where: query,
    data: data
}

对于 Android,将警报"(和标题"(如果适用))从顶级参数移动到您的数据参数内将防止 Parse 的 PushService 拦截推送通知并创建自己的状态栏通知.

For Android, moving "alert" (and "title" if applicable) from the top level parameters to within your data params will keep Parse's PushService from intercepting the push notif and creating its own status bar notification.

您现在可以禁用 Parse 的接收器并通过自定义广播接收器(由action"参数标识)自己实现通知.有点像黑客,但我需要自定义通知,如果您设置了警报或标题,似乎没有其他方法可以绕过 Parse 的 PushService 拦截它们.

You can now disable Parse's receiver and implement the notifications yourself through a custom broadcast receiver (identified by the "action" parameter). Kind of a hack, but I need custom notifs, and there doesn't seem to be another way to circumvent Parse's PushService from intercepting them if you have alert or title set.

这篇关于有没有办法在使用“警报"时阻止解析拦截我的通知?钥匙?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆