public override void OnSendError(string msgId, Exception exception) { // If the sending fails, obtain the error message. IHMSPushEvent hmsPushEvent = HMSPushEvent.Instance; hmsPushEvent.HMSOnSendError(msgId, ((BaseException)exception).ErrorCode, ((BaseException)exception).Message); }
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)); } } }