Xamarin中的Android ParsePushBroadcastReceiver

时间:2016-09-28 17:40:17

标签: java c# android parse-platform xamarin.android

我很忙"重建"用Android Java编写的应用程序到Xamarin C#

我需要将一个类扩展到NuGet上找到的ParsePushBroadcastReceiver库中的Parse,并且能够覆盖OnReceive方法。在java中,库是可扩展的,如无数StackOverflow问题所示,但在Xamarin中,类是密封的,无法扩展。

https://stackoverflow.com/a/26180181/1876355

How to add "ParsePushBroadcastReceiver.getActivity" to an application?

我无法弄清楚如何继续解决这个问题,因为现有的代码需要在OnReceive方法中执行。

enter image description here

任何想法?

1 个答案:

答案 0 :(得分:1)

Looks like a bug

也许您现在可以重新创建该类,然后在发布未来版本的Parse库时替换它?

namespace WorkAround.Parse 
{
    [Register("parse.ParsePushBroadcastReceiver")]
    public class ParsePushBroadcastReceiver : BroadcastReceiver 
    {
        internal const string KeyPushData = "com.parse.Data";
        internal const string ActionGcmRegisterResponse = "com.google.android.c2dm.intent.REGISTRATION";
        internal const string ActionGcmReceive = "com.google.android.c2dm.intent.RECEIVE";
        public override void OnReceive(Context context, Intent intent) {
            intent.SetClass(context, typeof(ParsePushService));
            ParseWakefulHelper.StartWakefulService(context, intent);
        }
    }
}