Example #1
0
        public override void OnNewToken(string token, Bundle bundle)
        {
            // Obtain a token.
            IHMSTokenEvent hmsTokenEvent = HMSInstanceId.Instance;

            hmsTokenEvent.HMSOnNewToken(token, bundle);
        }
Example #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));
                }
            }
        }
Example #3
0
        public override void OnTokenError(Exception exception, Bundle bundle)
        {
            IHMSTokenEvent hmsTokenEvent = HMSInstanceId.Instance;

            hmsTokenEvent.HMSOnTokenError(((BaseException)exception).ErrorCode, ((BaseException)exception).Message, bundle);
        }