Esempio n. 1
0
        public override void OnMessageReceived(RemoteMessage message)
        {
            //It get triggered when data message comes or a notification comes which as foreground attributes false
            IHMSPushEvent hmsPushEvent = HMSPushEvent.Instance;

            hmsPushEvent.HMSOnMessageReceived(message);
        }
Esempio n. 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));
                }
            }
        }