예제 #1
0
        public void Single()
        {
            var notification = new PushNotificationRequest
            {
                Payload = new PushPayload
                {
                    Alert = "My Alert",
                    Sound = "My Sound",
                    Badge = Badge.Increment()
                },
                Aliases = new List <string> {
                    "alias1"
                },
                Tags = new List <string> {
                    "tag1"
                },
                DeviceTokens = new List <string> {
                    "token1"
                },
                ExcludeTokens = new List <string> {
                    "exclude1"
                },
            };
            var text     = notification.Serialize().FormatAsJson();
            var expected = @"
{
  'aps': {
    'alert': 'My Alert',
    'badge': '+1',
    'sound': 'My Sound'
  },
  'device_tokens': [
    'token1'
  ],
  'aliases': [
    'alias1'
  ],
  'tags': [
    'tag1'
  ],
  'exclude_tokens': [
    'exclude1'
  ]
}".Replace("\r\n", "\n");

            Assert.AreEqual(expected, text);
        }
예제 #2
0
        public void Single()
        {
            var notification = new PushNotificationRequest
            {
                Payload = new PushPayload
                {
                    Alert = "My Alert",
                    Extra = new Dictionary <string, string>
                    {
                        { "a", "b" }
                    },
                },
                Aliases = new List <string> {
                    "alias1"
                },
                Tags = new List <string> {
                    "tag1"
                },
            };
            var text     = notification.Serialize().FormatAsJson();
            var expected = @"
{
  'android': {
    'alert': 'My Alert',
    'extra': {
      'a': 'b'
    }
  },
  'aliases': [
    'alias1'
  ],
  'tags': [
    'tag1'
  ]
}".Replace("\r\n", "\n");

            Assert.AreEqual(expected, text);
        }