ParsePushBroadcastReceiver

ParsePushBroadcastReceiver

我正忙于“重新创建”用Xamarin C#用Android Java编写的应用程序

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

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

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

我无法弄清楚该问题的解决方法,因为现有的代码需要在OnReceive方法中执行。

java - Xamarin中的Android ParsePushBroadcastReceiver-LMLPHP

有任何想法吗?

最佳答案

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);
        }
    }
}

10-06 10:37