Пример #1
0
        public override void OnMessageDelivered(string msgId, Exception exception)
        {
            // Obtain the error code and description.
            IHMSPushEvent hmsPushEvent = HMSPushEvent.Instance;

            hmsPushEvent.HMSOnMessageDelivered(msgId, ((BaseException)exception).ErrorCode, ((BaseException)exception).Message);
        }
Пример #2
0
        public override void OnReceive(Context context, Intent intent)
        {
            Bundle bundle = intent.Extras;

            IHMSTokenEvent hmsTokenEvent = HMSInstanceId.Instance;
            IHMSPushEvent  hmsPushEvent  = HMSPushEvent.Instance;

            if (bundle.ContainsKey(Method))
            {
                string method = intent.Extras.GetString(Method);
                if (method == ((Action <string, Bundle>)hmsTokenEvent.HMSOnNewToken).Method.Name)
                {
                    hmsTokenEvent.HMSOnNewToken(bundle.GetString(Token), bundle.GetBundle(Bundle));
                }
                else if (method == ((Action <RemoteMessage>)hmsPushEvent.HMSOnMessageReceived).Method.Name)
                {
                    hmsPushEvent.HMSOnMessageReceived(bundle.Get(Message) as RemoteMessage);
                }
                else if (method == ((Action <string>)hmsPushEvent.HMSOnMessageSent).Method.Name)
                {
                    hmsPushEvent.HMSOnMessageSent(bundle.GetString(MsgId));
                }
                else if (method == ((Action <string, int, string>)hmsPushEvent.HMSOnSendError).Method.Name)
                {
                    hmsPushEvent.HMSOnSendError(
                        bundle.GetString(MsgId),
                        bundle.GetBundle(Exception).GetInt(ErrorCode),
                        bundle.GetBundle(Exception).GetString(ErrorMessage));
                }
                else if (method == ((Action <string, int, string>)hmsPushEvent.HMSOnMessageDelivered).Method.Name)
                {
                    hmsPushEvent.HMSOnMessageDelivered(
                        bundle.GetString(MsgId),
                        bundle.GetBundle(Exception).GetInt(ErrorCode),
                        bundle.GetBundle(Exception).GetString(ErrorMessage));
                }
                else if (method == ((Action <int, string, Bundle>)hmsTokenEvent.HMSOnTokenError).Method.Name)
                {
                    hmsTokenEvent.HMSOnTokenError(
                        bundle.GetBundle(Exception).GetInt(ErrorCode),
                        bundle.GetBundle(Exception).GetString(ErrorMessage),
                        bundle.GetBundle(Bundle));
                }
            }
        }