/// <summary> /// 创建单播的消息(消息类型=消息)推送请求 /// </summary> /// <param name="pBaiduUserID"></param> /// <param name="pBaiduChannelID"></param> /// <param name="pDeviceType"></param> /// <param name="pMessage"></param> /// <param name="pMessageKey"></param> /// <returns></returns> public static PushMsgRequest CreateUnicastMessageRequest(string pBaiduUserID , string pBaiduChannelID , DeviceTypes?pDeviceType , string pMessage , string pMessageKey , PushTypes pushType = PushTypes.Unicast) { PushMsgRequest req = new PushMsgRequest(); req.PushType = pushType; if (!string.IsNullOrEmpty(pBaiduUserID)) { req.BaiduUserID = pBaiduUserID; } req.BaiduChannelID = pBaiduChannelID; req.DeviceType = pDeviceType; req.MessageType = MessageTypes.Message; req.Message = pMessage; if (!string.IsNullOrWhiteSpace(pMessageKey)) { req.BaiduMessageKey = pMessageKey; } // return(req); }
// TODO: Refactor this somewhere private void Push(float pushStrength, PushTypes pushType) { if (pushType == PushTypes.Veloctiy) { var rb = GetComponentInParent <Rigidbody>(); float magnitude = rb.velocity.magnitude; Vector3 velocityDirection = rb.velocity.normalized; rb.AddForce(-velocityDirection * pushStrength * magnitude, ForceMode.Impulse); } }
/// <summary> /// 创建单播的消息(消息类型=消息)推送请求 /// </summary> /// <param name="pType">类型:1-直接发送,其它放入数据库轮循</param> /// <param name="pChannelID">对应MessageChannel表中的ID</param> /// <param name="pBaiduUserID">百度用户ID</param> /// <param name="pBaiduChannelID">百度通道ID</param> /// <param name="pMessage">消息内容</param> /// <returns></returns> public static PushRequest CreateAndroidUnicastMessageRequest(int pType, int pChannelID, string pBaiduUserID , string pBaiduChannelID , string pMessage , PushTypes pushType = PushTypes.Unicast) { PushRequest mes = new PushRequest(); mes.PlatForm = 1; mes.Type = pType; mes.ChannelID = pChannelID; mes.Request = PushMsgRequestBuilder.CreateUnicastMessageRequest(pBaiduUserID, pBaiduChannelID, null, pMessage, null, pushType).ToJSON(); return(mes); }
/// <summary> /// 创建单播的消息(消息类型=通知)推送请求 /// </summary> /// <param name="pBaiduUserID"></param> /// <param name="pBaiduChannelID"></param> /// <param name="pMessageTitle"></param> /// <param name="pMessageDescription"></param> /// <returns></returns> public static PushMsgRequest CreateUnicastNotificationRequest(string pBaiduUserID , string pBaiduChannelID , string pMessageTitle , string pMessageDescription , PushTypes pushType = PushTypes.Unicast) { BaiduPushNotification msg = new BaiduPushNotification(); msg.Title = pMessageTitle; msg.Description = pMessageDescription; msg.OpenType = 2; msg.NotificationBuilderID = 0; msg.NotificationBasicStyle = 4; return(PushMsgRequestBuilder.CreateUnicastNotificationRequest(pBaiduUserID, pBaiduChannelID, null, msg, null, pushType)); }
private async Task <PushMessageResponse> sendPush( PushTypes pushType, string recipientId, string messageTitle, string messageBody, bool isPopUp, NotificationDataContainer properties ) { //Сделано пока что только для Device try { await _firebaseClient.Auth.AuthenticateAsync(); FirebasePushMessage message = new FirebasePushMessage() { Token = recipientId, Android = new Android() { Priority = Priority.High }, Notification = new Notification() { Body = messageTitle, Title = messageBody }, Data = properties.GetDictionary() }; return(await _firebaseClient.CloudMessaging.SendCloudMessageAsync(message)); } catch (Exception ex) { _logger.LogError($"Exception thrown in Firebase Push Sender: {ex.Message}, {ex.StackTrace}"); } return(null); }