2016-09-28 68 views
1

我很忙“再造”写在Android的Java来Xamarin C#应用程序的Android ParsePushBroadcastReceiver在Xamarin

我需要在一个类扩展到ParsePushBroadcastReceiver提供上的NuGet发现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

貌似这个bug已经被报道https://github.com/ParsePlatform/Parse-SDK-dotNET/issues/152 – foxanna

回答

1

Looks like a bug

也许你可以重新创建的类时解析库的未来版本发布时,现在再更换?

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

我复制你的整个的命名空间,包括'解析;','复制点解析网络SDK ...解析/内部/推/ Android/ParseWakefulHelper.cs的内容到WorkAround.Parse和扩展到':WorkAround.Parse.ParsPush ...'完美地工作 – Pierre

+1

很高兴听到它的帮助!只要记得在解决github问题时解决这个问题:) – flakes