1

So I'm using the Parse component from the Xamarin store in my MonoDroid app. So I was able to use the following code to store an object

ParseClient.Initialize ("appid", "windowskey");

var obj = new ParseObject("Note");
obj ["text"] = "Hello, world!  This is a Xamarin app using Parse!";
obj ["tags"] = new List<string> {"welcome", "xamarin", "parse"};
obj.SaveAsync ();

My real goal is to be able to do push notifications. Even though the above object stored, Parse did not register the device in the installations to be able to send push notifications. What else am I missing. Note: I'm doing this in the emulator but if i'm not mistaken it still should work.

4

1 回答 1

0

@basit-zia,是的,我做到了!我必须从 Java Parse SDK 为推送库创建一个绑定。我相信我能够剥离除必要元素之外的所有库。我不记得我到底做了什么。

然后在 Main Activity 类中,我将以下内容放入 OnStart() 方法中:

            // check for a notification
            if (Intent != null)
                try {
                string jsonString = Intent.Extras.GetString("com.parse.Data");
                PushObject jsonObj = JsonConvert.DeserializeObject<PushObject>(jsonString);

                if (jsonObj.alert != null) {
                    Toast.MakeText (BaseContext, jsonObj.alert, ToastLength.Long).Show ();
                }

                } catch (Exception e) {
                    Console.WriteLine ("JSONException: " + e.Message);
                }

并将以下内容放入 OnCreate() 方法中:

            Com.Parse.Parse.Initialize(this, "app id here"}, "client key here");
            PushService.SetDefaultPushCallback (this, this.Class);
            PushService.StartServiceIfRequired (this);
            ParseInstallation.CurrentInstallation.SaveInBackground ();
于 2014-02-14T15:11:49.103 回答