コード例 #1
0
        /// <summary>
        /// 推送单个设备,限iOS系统使用。
        /// </summary>
        /// <param name="deviceToken"></param>
        /// <param name="msg"></param>
        /// <param name="env"></param>
        /// <returns></returns>
        public string PushSingleDevice(string deviceToken, MessageIOS msg, iOSEnvironment env)
        {
            if (!isValidMessageType(msg, env))
            {
                return("{'ret_code':-1,'err_msg':'message type or environment error!'}");
            }

            if (!msg.isValid())
            {
                return("{'ret_code':-1,'err_msg':'message invalid!'}");
            }

            var param = new Dictionary <string, object>
            {
                { Constants.access_id, m_access_id },
                { Constants.expire_time, msg.getExpireTime() },
                { Constants.send_time, msg.getSendTime() },
                { Constants.device_token, deviceToken },
                { Constants.message_type, msg.getType() },
                { Constants.message, msg.toJson() },
                { Constants.timestamp, GetTimestamp() },
                { Constants.environment, env }
            };

            if (msg.getLoopInterval() > 0 && msg.getLoopTimes() > 0)
            {
                param.Add(Constants.loop_interval, msg.getLoopInterval());
                param.Add(Constants.loop_times, msg.getLoopTimes());
            }
            var ret = callRestful(RESTAPI_PUSHSINGLEDEVICE, param);

            return(ret);
        }
コード例 #2
0
        /// <summary>
        /// 创建批量推送消息,后续利用生成的 pushid 配合 PushAccountListMultiple
        /// 或 PushDeviceListMultiple 接口使用,限iOS系统使用。
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="env"></param>
        /// <returns></returns>
        public string CreateMultipush(MessageIOS msg, iOSEnvironment env)
        {
            if (!isValidMessageType(msg, env))
            {
                return("{'ret_code':-1,'err_msg':'message type or environment error!'}");
            }

            if (!msg.isValid())
            {
                return("{'ret_code':-1,'err_msg':'message invalid!'}");
            }

            var param = new Dictionary <string, object>
            {
                { Constants.access_id, m_access_id },
                { Constants.expire_time, msg.getExpireTime() },
                { Constants.message_type, msg.getType() },
                { Constants.message, msg.toJson() },
                { Constants.timestamp, GetTimestamp() },
                { Constants.environment, env }
            };
            var ret = callRestful(RESTAPI_CREATEMULTIPUSH, param);

            return(ret);
        }
コード例 #3
0
        /// <summary>
        /// 推送标签,限iOS系统使用。
        /// </summary>
        /// <param name="tagList"></param>
        /// <param name="tagOp"></param>
        /// <param name="msg"></param>
        /// <param name="env"></param>
        /// <returns></returns>
        public string PushTags(IEnumerable <string> tagList, Operator tagOp, MessageIOS msg,
                               iOSEnvironment env)
        {
            if (!isValidMessageType(msg, env))
            {
                return("{'ret_code':-1,'err_msg':'message type or environment error!'}");
            }
            if (!msg.isValid())
            {
                return("{'ret_code':-1,'err_msg':'message invalid!'}");
            }
            var param = new Dictionary <string, object>
            {
                { Constants.access_id, m_access_id },
                { Constants.expire_time, msg.getExpireTime() },
                { Constants.send_time, msg.getSendTime() },
                { Constants.message_type, msg.getType() },
                { Constants.tags_list, toJArray(tagList) },
                { Constants.tags_op, tagOp },
                { Constants.message, msg.toJson() },
                { Constants.timestamp, (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000 },
                { Constants.environment, env }
            };

            if (msg.getLoopInterval() > 0 && msg.getLoopTimes() > 0)
            {
                param.Add(Constants.loop_interval, msg.getLoopInterval());
                param.Add(Constants.loop_times, msg.getLoopTimes());
            }
            var ret = callRestful(RESTAPI_PUSHTAGS, param);

            return(ret);
        }
コード例 #4
0
        /// <summary>
        /// 推送单个账号,限iOS系统使用。
        /// </summary>
        /// <param name="account"></param>
        /// <param name="msg"></param>
        /// <param name="env"></param>
        /// <returns></returns>
        public string PushSingleAccount(string account, MessageIOS msg, iOSEnvironment env)
        {
            if (!isValidMessageType(msg, env))
            {
                return("{'ret_code':-1,'err_msg':'message type or environment error!'}");
            }
            if (!msg.isValid())
            {
                return("{'ret_code':-1,'err_msg':'message invalid!'}");
            }
            var param = new Dictionary <string, object>
            {
                { Constants.access_id, m_access_id },
                { Constants.expire_time, msg.getExpireTime() },
                { Constants.send_time, msg.getSendTime() },
                { Constants.account, account },
                { Constants.message_type, msg.getType() },
                { Constants.message, msg.toJson() },
                { Constants.timestamp, GetTimestamp() },
                { Constants.environment, env }
            };
            var ret = callRestful(RESTAPI_PUSHSINGLEACCOUNT, param);

            return(ret);
        }
コード例 #5
0
        /// <summary>
        /// 推送给指定的账号,限iOS系统使用。
        /// </summary>
        /// <param name="accessId"></param>
        /// <param name="secretKey"></param>
        /// <param name="content"></param>
        /// <param name="account"></param>
        /// <param name="env"></param>
        /// <returns></returns>
        public static string pushAccountIos(long accessId, string secretKey,
                                            string content, string account, iOSEnvironment env)
        {
            var message = new MessageIOS();

            message.setAlert(content);
            message.setBadge(1);
            message.setSound(Constants.beep_wav);

            var xinge = new XingeApp(accessId, secretKey);
            var ret   = xinge.PushSingleAccount(account, message, env);

            return(ret);
        }
コード例 #6
0
        /// <summary>
        /// 推送给绑定标签的设备,限iOS系统使用。
        /// </summary>
        /// <param name="accessId"></param>
        /// <param name="secretKey"></param>
        /// <param name="content"></param>
        /// <param name="tag"></param>
        /// <param name="env"></param>
        /// <returns></returns>
        public static string pushTagIos(long accessId, string secretKey,
                                        string content, string tag, iOSEnvironment env)
        {
            var message = new MessageIOS();

            message.setAlert(content);
            message.setBadge(1);
            message.setSound(Constants.beep_wav);

            var xinge   = new XingeApp(accessId, secretKey);
            var tagList = new List <string> {
                tag
            };
            string ret = xinge.PushTags(tagList, OR, message, env);

            return(ret);
        }
コード例 #7
0
 public MonoCompat(string app_id, long access_id, string secret_key, iOSEnvironment env, HttpClient httpClient) : base(app_id, access_id, secret_key, env, httpClient)
 {
 }
コード例 #8
0
        public void TestMethod1()
        {
            XingePushClient.InitHttpClientCompatDefaultMagic();

            AudienceType type = new PushRequest <MessageiOS> .Token();

            var m = new Model
            {
                AudienceType = type,
                TimeInterval = new TimeInterval
                {
                    StartHour = 1,
                    StartMin  = 2,
                    EndHour   = 3,
                    EndMin    = 4,
                },
                Operator1         = Operator.AND,
                Operator2         = Operator.OR,
                True              = 1,
                False             = 0,
                Null              = null,
                NullableFalse     = 0U,
                NullableTrue      = 1U,
                ThreeDays         = TimeSpan.FromDays(3),
                UInt32S           = 60U,
                Int32S            = 120,
                NullableSeconds   = null,
                NullableThreeDays = TimeSpan.FromDays(3),
                NullableUInt32S   = 60U,
                NullableInt32S    = 120,
                TagTokenPair      = new TagTokenPair
                {
                    Tag   = "abc",
                    Token = "qwert"
                },
                TagTokenPairCompat = new Compat.TagTokenPair
                {
                    tag   = "abc1",
                    token = "qwert1"
                },
                Now1            = DateTime.Now,
                Now2            = DateTimeOffset.Now,
                TimeEmpty1      = null,
                TimeEmpty2      = null,
                TimeNull2       = string.Empty,
                D1              = Internal.Constants.DefaultMessageSendTime,
                D2              = Internal.Constants.DefaultMessageSendTime,
                iOSEnv1         = 1,
                iOSEnv2         = 2,
                iOSEnvNullable  = null,
                iOSEnv1Nullable = 1,
                iOSEnv2Nullable = 2,
            };

            m.iOSEnv1_V3         = m.iOSEnv1;
            m.iOSEnv2_V3         = m.iOSEnv2;
            m.iOSEnvNullable_V3  = m.iOSEnvNullable;
            m.iOSEnv1Nullable_V3 = m.iOSEnv1Nullable;
            m.iOSEnv2Nullable_V3 = m.iOSEnv2Nullable;

            var envE = m.iOSEnv1_V3 == m.iOSEnv1 &&
                       m.iOSEnv2_V3 == m.iOSEnv2 &&
                       m.iOSEnvNullable_V3 == m.iOSEnvNullable &&
                       m.iOSEnv1Nullable_V3 == m.iOSEnv1Nullable &&
                       m.iOSEnv2Nullable_V3 == m.iOSEnv2Nullable;

            Assert.IsTrue(envE, nameof(envE));

            var json  = m.Serialize();
            var obj   = json.Deserialize <Model>();
            var json2 = obj.Serialize();

            var isOK = json == json2;

            Assert.IsTrue(isOK, nameof(isOK));

            var iOSEnv = new iOSEnvironment(1);

            Assert.IsTrue(iOSEnv == iOSEnvironment.Production, nameof(iOSEnv));

            iOSEnvironmentV3 iOSEnv3 = iOSEnv;

            Assert.IsTrue(iOSEnv3 == iOSEnvironmentV3.Production, nameof(iOSEnv3));

            Console.WriteLine(json2);

            Console.WriteLine("Size of C# bool is: {0}", sizeof(bool));
            Console.WriteLine("Size of C# char is: {0}", sizeof(char));
            Console.WriteLine("Size of C# short is: {0}", sizeof(short));
            Console.WriteLine("Size of C# int is: {0}", sizeof(int));
            Console.WriteLine("Size of C# long is: {0}", sizeof(long));
            Console.WriteLine("Size of Operator: {0}", Marshal.SizeOf(typeof(Operator)));
            Console.WriteLine("Size of DigitBoolean: {0}", Marshal.SizeOf(typeof(DigitBoolean)));
            Console.WriteLine("Size of Seconds: {0}", Marshal.SizeOf(typeof(Second)));
            Console.WriteLine("Size of NullableDateTime: {0}", Marshal.SizeOf(typeof(NullableDateTime)));
            Console.WriteLine("Size of iOSEnvironment: {0}", Marshal.SizeOf(typeof(iOSEnvironment)));
            Console.WriteLine("Size of iOSEnvironmentV3: {0}", Marshal.SizeOf(typeof(iOSEnvironmentV3)));
        }
コード例 #9
0
 internal iOSEnvironmentV3(iOSEnvironment value) : this(value.Value)
 {
 }
コード例 #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public bool Equals(iOSEnvironment other)
 {
     return(Equals(this, new iOSEnvironmentV3(other)));
 }
コード例 #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="left"></param>
 /// <param name="right"></param>
 /// <returns></returns>
 public static bool Equals(iOSEnvironment left, iOSEnvironmentV3 right)
 {
     return(Equals(new iOSEnvironmentV3(left), right));
 }
コード例 #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="left"></param>
 /// <param name="right"></param>
 /// <returns></returns>
 public static bool Equals(iOSEnvironmentV3 left, iOSEnvironment right)
 {
     return(Equals(left, new iOSEnvironmentV3(right)));
 }
コード例 #13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static uint ConvertTo(iOSEnvironment value)
        {
            uint p0 = value;

            return(p0);
        }