private void RegPushByTags(int pushType, List <string> tags, object id, string title, string subTitle, string noticeId) { PushPayload pushEntity = new PushPayload { Audience = new { tag = tags.ToArray() }, Platform = "all", Notification = new Notification { Alert = title, IOS = new IOS { Alert = new { title = title, body = subTitle }, Extras = PushHelper.GetNewExtras(pushType, id, title, subTitle, noticeId) }, Android = new Android { Alert = subTitle, Title = title, Extras = PushHelper.GetNewExtras(pushType, id, title, subTitle, noticeId) } }, Message = new Message { Title = title, Content = subTitle, Extras = PushHelper.GetNewExtras(pushType, id, title, subTitle, noticeId) }, Options = new Options { IsApnsProduction = IsPushProduction } }; var agent = new JPushAgent(); agent.Push(pushEntity); }
public void PushOrderPayed(Guid orderId) { var order = new OrderDAC().GetOrderByOrderId(orderId); var coin = new CryptocurrencyDAC().GetById(order.CryptoId); var agent = new JPushAgent(); var regId = RedisHelper.StringGet($"{FiiiPOS_APP_Notice_MerchantId}:{order.MerchantAccountId}"); var lang = RedisHelper.StringGet(REDIS_LANGUAGE_DBINDEX, $"{FiiiPOS_APP_Language_MerchantId}:{order.MerchantAccountId}") ?? "en"; var titleKey = "ReceiptTitle"; var subTitleKey = "ReceiptSubTitle"; var content = ResourceHelper.FiiiPos.GetFormatResource(titleKey, lang, coin.Code); var subTitle = ResourceHelper.FiiiPos.GetResource(subTitleKey, lang); string noticeId = ""; //写MongoDB [收款成功] MessagesComponent.AddMessage(order.MerchantAccountId, UserType.Merchant, order.Id.ToString(), FiiiPayPushType.TYPE_RECEIPT, titleKey, subTitleKey, coin.Code, content, subTitle, out noticeId); var result = agent.Push(new PushPayload { Audience = new { registration_id = new List <string> { regId } }, Platform = "all", Notification = new Notification { Alert = content, Android = new Android { Alert = subTitle, Title = content, Extras = PushHelper.GetNewExtras(FiiiPayPushType.TYPE_RECEIPT, orderId, content, subTitle, noticeId) } }, Message = new Message { Content = content, Extras = PushHelper.GetNewExtras(FiiiPayPushType.TYPE_RECEIPT, orderId, content, subTitle, noticeId) }, Options = new Options { IsApnsProduction = IsPushProduction } }); LogHelper.Info($"--------{lang}------{content}----------{subTitle}"); }
public void RemoveTagsByUserId(Guid userId) { var redisKey = $"FiiiPay:Notice:UserId:{userId}"; var regId = RedisHelper.StringGet(redisKey); if (IsNullOrEmpty(regId)) { return; } var agent = new JPushAgent(); agent.UpdateDeviceInfo(regId, new DevicePayload { Tags = "" }); RedisHelper.KeyDelete(redisKey); }
private void RegPush(int pushType, List <string> regIdList, object id, string title, string subTitle, string noticeId, bool SendMessage = false) { if (regIdList == null || string.IsNullOrEmpty(regIdList[0])) { return; } PushPayload pushEntity = new PushPayload { Audience = new { registration_id = regIdList }, Platform = "all", Notification = new Notification { Alert = title, IOS = new IOS { Alert = new { title = title, body = subTitle }, Extras = PushHelper.GetNewExtras(pushType, id, title, subTitle, noticeId) }, Android = new Android { Alert = subTitle, Title = title, Extras = PushHelper.GetNewExtras(pushType, id, title, subTitle, noticeId) } }, Options = new Options { IsApnsProduction = IsPushProduction } }; if (SendMessage) { pushEntity.Message = new Message { Title = title, Content = subTitle, Extras = PushHelper.GetNewExtras(pushType, id, title, subTitle, noticeId) }; } var agent = new JPushAgent(); var result = agent.Push(pushEntity); LogHelper.Info($"regids:{string.Join(",",regIdList)} ;result:{result}"); }
public void BindNoticeRegId(Guid userId, BindNoticeRegIdIM im) { var agent = new JPushAgent(); RemoveTagsByUserId(userId); var tags = new List <string> { Constant.JPUSH_TAG }; var result = agent.UpdateDeviceInfo(im.NoticeRegId, new DevicePayload { Tags = new Dictionary <string, object> { { "add", tags.ToArray() } } }); var redisKey = $"FiiiPay:Notice:UserId:{userId}"; RedisHelper.StringSet(redisKey, im.NoticeRegId); }
public bool BindNoticeRegId(Guid accountId, BindNoticeRegIdIM im) { RemoveRegInfoByUserId(accountId); var agent = new JPushAgent(); var tags = new List <string> { Constant.JPUSH_TAG }; agent.UpdateDeviceInfo(im.NoticeRegId, new DevicePayload { Tags = new Dictionary <string, object> { { "add", tags.ToArray() } } }); string keyOfNotice = $"{RedisKeys.FiiiPOS_APP_Notice_MerchantId}:{accountId}"; RedisHelper.StringSet(keyOfNotice, im.NoticeRegId); return(true); }