private void registerDevice(string channelUri) { string device_uuid = this.getDeviceUUID(); if (device_uuid == null) { return; //emulators } Dictionary <string, string> credentials = new Dictionary <string, string>(); try { //loop over blogs and retrieves the list of .com accounts added to the app List <Blog> blogs = DataService.Current.Blogs.ToList(); foreach (Blog currentBlog in blogs) { if (currentBlog.isWPcom() || currentBlog.hasJetpack()) { if (currentBlog.isWPcom()) { if (!credentials.ContainsKey(currentBlog.Username)) { credentials.Add(currentBlog.Username, currentBlog.Password); } } else { if (currentBlog.DotcomUsername != null && currentBlog.DotcomPassword != null && !credentials.ContainsKey(currentBlog.DotcomUsername)) { credentials.Add(currentBlog.DotcomUsername, currentBlog.DotcomPassword); } } } } } catch (Exception e) { // DataService.Current.Blogs could be null under certain circumstances at startup. Why? Utils.Tools.LogException(String.Format("Could not access the blogs list. {0}", e.Message), e); } bool sendBlogsList = true; foreach (KeyValuePair <String, String> entry in credentials) { // do something with entry.Value or entry.Key RegisterPushNotificationToken rpc = new RegisterPushNotificationToken(pushNotificationURL, entry.Key, entry.Value, "0", device_uuid, channelUri, getDeviceName()); if (sendBlogsList) { sendBlogsList = false; //Just send one blog list when thre more than one account rpc.Completed += OnRegisterTokenCompleted; } rpc.ExecuteAsync(); } }
private void OnRegisterTokenCompleted(object sender, XMLRPCCompletedEventArgs <BooleanResponseObject> args) { RegisterPushNotificationToken rpc = sender as RegisterPushNotificationToken; rpc.Completed -= OnRegisterTokenCompleted; if (null == args.Error) { this.sendBlogsList(); return; } else { Exception e = args.Error; Utils.Tools.LogException(String.Format("Register Token error occurred. {0}", e.Message), e); } }
private void registerDevice(string channelUri) { string device_uuid = this.getDeviceUUID(); if (device_uuid == null) return; //emulators Dictionary<string, string> credentials = new Dictionary<string,string>(); try { //loop over blogs and retrieves the list of .com accounts added to the app List<Blog> blogs = DataService.Current.Blogs.ToList(); foreach (Blog currentBlog in blogs) { if (currentBlog.isWPcom() || currentBlog.hasJetpack()) { if (currentBlog.isWPcom()) { if (!credentials.ContainsKey(currentBlog.Username)) credentials.Add(currentBlog.Username, currentBlog.Password); } else { if (currentBlog.DotcomUsername != null && currentBlog.DotcomPassword != null && !credentials.ContainsKey(currentBlog.DotcomUsername)) credentials.Add(currentBlog.DotcomUsername, currentBlog.DotcomPassword); } } } } catch (Exception e) { // DataService.Current.Blogs could be null under certain circumstances at startup. Why? Utils.Tools.LogException(String.Format("Could not access the blogs list. {0}", e.Message), e); } bool sendBlogsList = true; foreach (KeyValuePair<String, String> entry in credentials) { // do something with entry.Value or entry.Key RegisterPushNotificationToken rpc = new RegisterPushNotificationToken(pushNotificationURL, entry.Key, entry.Value, "0", device_uuid, channelUri, getDeviceName()); if (sendBlogsList) { sendBlogsList = false; //Just send one blog list when thre more than one account rpc.Completed += OnRegisterTokenCompleted; } rpc.ExecuteAsync(); } }