private void SaveRecord() { if (this.record == null) { this.record = new AndroidFCMRecord(); } this.record.SenderId = this.senderIdTextBox.Text; this.record.AppId = this.appIdTextBox.Text; List <string> tokens = new List <string>(); foreach (var obj in this.tokenListView.Items) { TokenItem item = (TokenItem)obj; tokens.Add(item.Token); } this.record.DeviceTokens = tokens; string json = this.record.SerializeToJson(); string path = this.RecordPath; File.WriteAllText(path, json); }
public AndroidFCMWindow(AndroidSenderType type) { InitializeComponent(); this.senderType = type; switch (this.senderType) { case AndroidSenderType.FCM: this.Title = "Android FCM"; break; case AndroidSenderType.GCM: this.Title = "Android GCM"; break; } string path = this.RecordPath; if (File.Exists(path)) { // load last record try { this.record = JsonUtility.DeserializeFromJson <AndroidFCMRecord>(File.ReadAllText(path)); this.senderIdTextBox.Text = this.record.SenderId; this.appIdTextBox.Text = this.record.AppId; if (this.record.DeviceTokens != null) { foreach (string token in this.record.DeviceTokens) { TokenItem item = new TokenItem(); item.Token = token; this.tokenListView.Items.Add(item); } } } catch { } } }