如何配置解析SDK客户端以在统一3D模式下接收推送通知

时间:2019-06-12 12:34:12

标签: unity3d parse-platform

我更改了一些代码,并为.net插件编译了最新的解析SDK,以实现统一。现在,我想配置统一客户端应用程序以接收推送通知(尤其是android)。我不知道如何配置它,我只是找到了一些代码来接收或显示通知,而不是像所有权限或将云消息密钥放在何处一样如何配置它。如果有人可以帮助我?谢谢

1 个答案:

答案 0 :(得分:0)

是的,当然。我发现了一些奇怪的东西,我有两个消息接收器firebase和parse,当应用程序位于前台`

时,firebase接收器可以工作
    //Events subscription
    private void Awake()
    {
        instance  = this;
        Firebase.Messaging.FirebaseMessaging.TokenReceived += OnTokenReceived;
        ParsePush.ParsePushNotificationReceived += OnMessageReceiveByParse;
        Firebase.Messaging.FirebaseMessaging.MessageReceived += 
        OnMessageReceiveByFirebase;
    }

    // method call when firebase message received
    void OnMessageReceiveByFirebase(object 
sender,Firebase.Messaging.MessageReceivedEventArgs args)
    {
        Debug.Log("Message from firebase : " + args.Message);
    }

    // method call when parse message received
    void OnMessageReceiveByParse(object sender, ParsePushNotificationEventArgs args)
    {

        Debug.Log("Message from Parse Server : " + args.Payload);
    }

    // parse guide receiver implementation
    void cool(object sender, ParsePushNotificationEventArgs args)
    {
#if UNITY_ANDROID
        AndroidJavaClass parseUnityHelper = new AndroidJavaClass("com.parse.ParsePushUnityHelper");
        AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");

        // Call default behavior.
        parseUnityHelper.CallStatic("handleParsePushNotificationReceived", currentActivity, args.StringPayload);
#endif
    }

`

启动应用程序时,我使用android studio进行调试,始终显示错误,我使用类解析sdk而不编译dll:该类在我的sdk中不存在:

    (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)
2019-07-12 09:12:33.968 14620-14663/? E/Unity: AndroidJavaException: java.lang.ClassNotFoundException: com.parse.ParsePushUnityHelper
    java.lang.ClassNotFoundException: com.parse.ParsePushUnityHelper
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:453)
        at java.lang.Class.forName(Class.java:378)
        at com.unity3d.player.UnityPlayer.nativePause(Native Method)
        at com.unity3d.player.UnityPlayer.l(Unknown Source:0)
        at com.unity3d.player.UnityPlayer$22.run(Unknown Source:2)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at com.unity3d.player.UnityPlayer$e.run(Unknown Source:32)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.parse.ParsePushUnityHelper" on path: DexPathList[[zip file "/data/app/com.wmg.mascothunt-bUi8a5Uz_-d12IhMoYJuOQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.wmg.mascothunt-bUi8a5Uz_-d12IhMoYJuOQ==/lib/arm, /data/app/com.wmg.mascothunt-bUi8a5Uz_-d12IhMoYJuOQ==/base.a