emas.go 19.6 KB
Newer Older
hujiebin's avatar
hujiebin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565
package emas

import (
	"encoding/json"
	"fmt"
	"git.hilo.cn/hilo-common/mylogrus"
	"git.hilo.cn/hilo-common/resource/config"
	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
	"github.com/aliyun/alibaba-cloud-sdk-go/services/push"
	"strings"
)

var EmasClient *push.Client

func SendMsg(externalId string, deviceType string, body string) error {
	if strings.ToLower(deviceType) == "android" {
		return sendAndroidMsg(externalId, body)
	} else if strings.ToLower(deviceType) == "ios" {
		return sendIosMsg(externalId, body)
	} else {
		err1 := sendAndroidMsg(externalId, body)
		err2 := sendIosMsg(externalId, body)
		if err1 != nil {
			return err1
		} else if err2 != nil {
			return err2
		}
		return nil
	}
}

func SendNotice(externalId string, deviceType string, title string, body string) error {
	if strings.ToLower(deviceType) == "android" {
		return sendAndroidNotice(externalId, title, body)
	} else if strings.ToLower(deviceType) == "ios" {
		return sendIosNotice(externalId, title, body)
	} else {
		err1 := sendAndroidNotice(externalId, title, body)
		err2 := sendIosNotice(externalId, title, body)
		if err1 != nil {
			return err1
		} else if err2 != nil {
			return err2
		}
		mylogrus.MyLog.Infof("emas send notice success externalId:%v", externalId)
		return nil
	}
}

func SendAndroidNoticeAll(title string, body string) error {

	request := push.CreatePushRequest()
	request.Scheme = "https"

	request.AppKey = requests.Integer(config.GetEmasAndroidAppKey())
	request.PushType = "NOTICE"
	request.DeviceType = "ANDROID"
	request.Target = "ALL"
	request.TargetValue = "ALL"
	request.Body = body
	request.Title = title
	//request.JobKey = "1"
	//request.SendSpeed = requests.NewInteger(1)
	//产品决定
	request.StoreOffline = requests.NewBoolean(true)
	//request.PushTime = "1"
	//默认是72小时
	//request.ExpireTime = time.Now().Add(time.Duration(time.Hour * 72)).UTC().Format(time.RFC3339)
	/*	request.iOSApnsEnv = "1"
		request.iOSRemind = requests.NewBoolean(false)
		request.iOSRemindBody = "1"
		request.iOSBadge = requests.NewInteger(1)
		request.iOSBadgeAutoIncrement = requests.NewBoolean(false)
		request.iOSSilentNotification = requests.NewBoolean(false)
		request.iOSMusic = "1"
		request.iOSSubtitle = "1"
		request.iOSNotificationCategory = "1"
		request.iOSMutableContent = requests.NewBoolean(false)
		request.iOSExtParameters = "1"*/
	request.AndroidNotifyType = "BOTH"
	request.AndroidOpenType = "APPLICATION"
	//request.AndroidActivity = "1"
	//request.AndroidMusic = "1"
	//request.AndroidOpenUrl = "1"
	//request.AndroidXiaoMiActivity = "1"
	//request.AndroidXiaoMiNotifyTitle = "1"
	//request.AndroidXiaoMiNotifyBody = "1"
	request.AndroidPopupActivity = "MainActivity"
	request.AndroidPopupTitle = title
	request.AndroidPopupBody = body
	//request.AndroidNotificationBarType = requests.NewInteger(1)
	//request.AndroidNotificationBarPriority = requests.NewInteger(1)
	//request.AndroidExtParameters = "1"
	request.AndroidRemind = requests.NewBoolean(true)
	//产品未给信息
	request.AndroidNotificationChannel = "com.qiahao.nextvideo_channel_random_pairing"
	//request.AndroidNotificationChannel = "2000"
	//request.AndroidNotificationXiaomiChannel = "1000"
	//
	//request.SmsTemplateName = "1"
	//request.SmsSignName = "1"
	//request.SmsParams = "1"
	//request.SmsDelaySecs = requests.NewInteger(1)
	//request.SmsSendPolicy = requests.NewInteger(1)

	//产品未给信息
	//request.AndroidNotificationVivoChannel = "1"
	//request.AndroidNotificationHuaweiChannel = "1"

	//request.AndroidNotificationNotifyId = requests.NewInteger(1)
	//request.iOSNotificationCollapseId = "1"

	//mylogrus.MyLog.Infof("emas sendAndroidNotice expireTime:%v ", request.ExpireTime)
	response, err := EmasClient.Push(request)
	if err != nil {
		buf, _ := json.Marshal(response)
		mylogrus.MyLog.Errorf("emas sendAndroidNoticeAll fail err:%v title:%v body:%v response:%v", err, title, body, string(buf))
	} else {
		mylogrus.MyLog.Infof("emas sendAndroidNoticeAll success title:%v body:%v", title, body)
	}
	return err
}

func SendIosNoticeAll(title string, body string) error {
	requestIOS := push.CreatePushNoticeToiOSRequest()
	requestIOS.Scheme = "https"
	requestIOS.AppKey = requests.Integer(config.GetEmasIosAppKey())
	requestIOS.Target = "ALL"
	requestIOS.TargetValue = "ALL"
	requestIOS.Body = body
	requestIOS.Title = title
	requestIOS.ApnsEnv = config.GetEmasApns()
	response, err := EmasClient.PushNoticeToiOS(requestIOS)
	if err != nil {
		buf, _ := json.Marshal(response)
		mylogrus.MyLog.Errorf("emas SendIosNoticeAll fail err:%v response:%#v, title:%v, body:%v, apnsEnv:%v", err, string(buf), title, body, config.GetEmasApns())
	} else {
		mylogrus.MyLog.Infof("emas SendIosNoticeAll success title:%v body:%v", title, body)
	}
	return err
}

func sendAndroidNotice(externalId string, title string, body string) error {

	request := push.CreatePushRequest()
	request.Scheme = "https"

	request.AppKey = requests.Integer(config.GetEmasAndroidAppKey())
	request.PushType = "NOTICE"
	request.DeviceType = "ANDROID"
	request.Target = "ACCOUNT"
	request.TargetValue = externalId
	request.Body = body
	request.Title = title
	//request.JobKey = "1"
	//request.SendSpeed = requests.NewInteger(1)
	//产品决定
	request.StoreOffline = requests.NewBoolean(true)
	//request.PushTime = "1"
	//默认是72小时
	//request.ExpireTime = time.Now().Add(time.Duration(time.Hour * 72)).UTC().Format(time.RFC3339)
	/*	request.iOSApnsEnv = "1"
		request.iOSRemind = requests.NewBoolean(false)
		request.iOSRemindBody = "1"
		request.iOSBadge = requests.NewInteger(1)
		request.iOSBadgeAutoIncrement = requests.NewBoolean(false)
		request.iOSSilentNotification = requests.NewBoolean(false)
		request.iOSMusic = "1"
		request.iOSSubtitle = "1"
		request.iOSNotificationCategory = "1"
		request.iOSMutableContent = requests.NewBoolean(false)
		request.iOSExtParameters = "1"*/
	request.AndroidNotifyType = "BOTH"
	request.AndroidOpenType = "APPLICATION"
	//request.AndroidActivity = "1"
	//request.AndroidMusic = "1"
	//request.AndroidOpenUrl = "1"
	//request.AndroidXiaoMiActivity = "1"
	//request.AndroidXiaoMiNotifyTitle = "1"
	//request.AndroidXiaoMiNotifyBody = "1"
	request.AndroidPopupActivity = "MainActivity"
	request.AndroidPopupTitle = title
	request.AndroidPopupBody = body
	//request.AndroidNotificationBarType = requests.NewInteger(1)
	//request.AndroidNotificationBarPriority = requests.NewInteger(1)
	//request.AndroidExtParameters = "1"
	request.AndroidRemind = requests.NewBoolean(true)
	//产品未给信息
	request.AndroidNotificationChannel = "com.qiahao.nextvideo_channel_random_pairing"
	//request.AndroidNotificationChannel = "2000"
	//request.AndroidNotificationXiaomiChannel = "1000"
	//
	//request.SmsTemplateName = "1"
	//request.SmsSignName = "1"
	//request.SmsParams = "1"
	//request.SmsDelaySecs = requests.NewInteger(1)
	//request.SmsSendPolicy = requests.NewInteger(1)

	//产品未给信息
	//request.AndroidNotificationVivoChannel = "1"
	//request.AndroidNotificationHuaweiChannel = "1"

	//request.AndroidNotificationNotifyId = requests.NewInteger(1)
	//request.iOSNotificationCollapseId = "1"

	//mylogrus.MyLog.Infof("emas sendAndroidNotice expireTime:%v ", request.ExpireTime)
	response, err := EmasClient.Push(request)
	if err != nil {
		buf, _ := json.Marshal(response)
		mylogrus.MyLog.Errorf("emas sendAndroidNotice fail err:%v externalId:%v, title:%v, body:%v response:%#v", err, externalId, title, body, string(buf))
	} else {
		mylogrus.MyLog.Infof("emas sendAndroidNotice success externalId:%v, title:%v body:%v", externalId, title, body)
	}
	return err
}

func SendMultNotice(externalIds []string, title string, body string, deviceType string) (string, error) {
	if strings.ToLower(deviceType) == "android" {
		return SendMultAndroidNotice(externalIds, title, body)
	} else if strings.ToLower(deviceType) == "ios" {
		return SendMultIosNotice(externalIds, title, body)
	} else {
		return "", fmt.Errorf("deviceType:%v not find", deviceType)
	}
}

func SendMultIosNotice(externalIds []string, title string, body string) (string, error) {
	externalIdStr := ""
	if len(externalIds) > 0 {
		externalIdStr += externalIds[0]
	}
	for i := 1; i < len(externalIds); i++ {
		externalIdStr = externalIdStr + "," + externalIds[i]
	}

	requestIOS := push.CreatePushNoticeToiOSRequest()
	requestIOS.Scheme = "https"
	requestIOS.AppKey = requests.Integer(config.GetEmasIosAppKey())
	requestIOS.Target = "ACCOUNT"
	requestIOS.TargetValue = externalIdStr
	requestIOS.Body = body
	requestIOS.Title = title
	requestIOS.ApnsEnv = config.GetEmasApns()
	response, err := EmasClient.PushNoticeToiOS(requestIOS)
	if err != nil {
		buf, _ := json.Marshal(response)
		mylogrus.MyLog.Errorf("emas SendMultIosNoticeAll fail err:%v response:%#v, title:%v, body:%v, apnsEnv:%v", err, string(buf), title, body, config.GetEmasApns())
	} else {
		mylogrus.MyLog.Infof("emas SendMultIosNoticeAll success title:%v body:%v", title, body)
	}
	messageId := ""
	if response != nil {
		messageId = response.MessageId
	}

	return messageId, err
}

func SendMultAndroidNotice(externalIds []string, title string, body string) (string, error) {
	externalIdStr := ""
	if len(externalIds) > 0 {
		externalIdStr += externalIds[0]
	}
	for i := 1; i < len(externalIds); i++ {
		externalIdStr = externalIdStr + "," + externalIds[i]
	}

	request := push.CreatePushRequest()
	request.Scheme = "https"

	request.AppKey = requests.Integer(config.GetEmasAndroidAppKey())
	request.PushType = "NOTICE"
	request.DeviceType = "ALL"
	request.Target = "ACCOUNT"
	request.TargetValue = externalIdStr
	request.Body = body
	request.Title = title
	//request.JobKey = "1"
	//request.SendSpeed = requests.NewInteger(1)
	//产品决定
	request.StoreOffline = requests.NewBoolean(true)
	//request.PushTime = "1"
	//默认是72小时
	//request.ExpireTime = time.Now().Add(time.Duration(time.Hour * 72)).UTC().Format(time.RFC3339)
	/*	request.iOSApnsEnv = "1"
		request.iOSRemind = requests.NewBoolean(false)
		request.iOSRemindBody = "1"
		request.iOSBadge = requests.NewInteger(1)
		request.iOSBadgeAutoIncrement = requests.NewBoolean(false)
		request.iOSSilentNotification = requests.NewBoolean(false)
		request.iOSMusic = "1"
		request.iOSSubtitle = "1"
		request.iOSNotificationCategory = "1"
		request.iOSMutableContent = requests.NewBoolean(false)
		request.iOSExtParameters = "1"*/
	request.AndroidNotifyType = "BOTH"
	request.AndroidOpenType = "APPLICATION"
	//request.AndroidActivity = "1"
	//request.AndroidMusic = "1"
	//request.AndroidOpenUrl = "1"
	//request.AndroidXiaoMiActivity = "1"
	//request.AndroidXiaoMiNotifyTitle = "1"
	//request.AndroidXiaoMiNotifyBody = "1"
	request.AndroidPopupActivity = "MainActivity"
	request.AndroidPopupTitle = title
	request.AndroidPopupBody = body
	//request.AndroidNotificationBarType = requests.NewInteger(1)
	//request.AndroidNotificationBarPriority = requests.NewInteger(1)
	//request.AndroidExtParameters = "1"
	request.AndroidRemind = requests.NewBoolean(true)
	//产品未给信息
	request.AndroidNotificationChannel = "com.qiahao.nextvideo_channel_random_pairing"
	//request.AndroidNotificationChannel = "2000"
	//request.AndroidNotificationXiaomiChannel = "1000"
	//
	//request.SmsTemplateName = "1"
	//request.SmsSignName = "1"
	//request.SmsParams = "1"
	//request.SmsDelaySecs = requests.NewInteger(1)
	//request.SmsSendPolicy = requests.NewInteger(1)

	//产品未给信息
	//request.AndroidNotificationVivoChannel = "1"
	//request.AndroidNotificationHuaweiChannel = "1"

	//request.AndroidNotificationNotifyId = requests.NewInteger(1)
	//request.iOSNotificationCollapseId = "1"

	//mylogrus.MyLog.Infof("emas sendAndroidNotice expireTime:%v ", request.ExpireTime)
	response, err := EmasClient.Push(request)
	if err != nil {
		buf, _ := json.Marshal(response)
		mylogrus.MyLog.Errorf("emas sendAndroidNotice fail err:%v externalId:%v, title:%v, body:%v response:%#v", err, externalIds, title, body, string(buf))
	} else {
		mylogrus.MyLog.Infof("emas sendAndroidNotice success externalId:%v, title:%v body:%v", externalIds, title, body)
	}

	messageId := ""
	if response != nil {
		messageId = response.MessageId
	}

	return messageId, err
}

/*func sendAndroidNotice(externalId string, title string, body string) error {

	requestAndroid := push.CreatePushNoticeToAndroidRequest()
	requestAndroid.Scheme = "https"
	requestAndroid.AppKey = requests.Integer(config.GetEmasAndroidAppKey())
	requestAndroid.Target = "ACCOUNT"
	requestAndroid.TargetValue = externalId
	requestAndroid.Body = body
	requestAndroid.Title = title

	response, err := EmasClient.PushNoticeToAndroid(requestAndroid)
	if err != nil {
		mylogrus.MyLog.Errorf("emas sendAndroidNotice externalId:%v, fail, response:%#v", externalId, response)
	} else {
		mylogrus.MyLog.Errorf("emas sendAndroidNotice externalId:%v, success", externalId)
	}

	return err
}*/

func sendIosNotice(externalId string, title string, body string) error {
	requestIOS := push.CreatePushNoticeToiOSRequest()
	requestIOS.Scheme = "https"
	requestIOS.AppKey = requests.Integer(config.GetEmasIosAppKey())
	requestIOS.Target = "ACCOUNT"
	requestIOS.TargetValue = externalId
	requestIOS.Body = body
	requestIOS.Title = title
	requestIOS.ApnsEnv = config.GetEmasApns()
	response, err := EmasClient.PushNoticeToiOS(requestIOS)
	if err != nil {
		buf, _ := json.Marshal(response)
		mylogrus.MyLog.Errorf("emas sendIosNotice fail err:%v externalId:%v response:%#v, title:%v, body:%v, apnsEnv:%v", err, externalId, string(buf), title, body, config.GetEmasApns())
	} else {
		mylogrus.MyLog.Infof("emas sendIosNotice success externalId:%v  title:%v body:%v", externalId, title, body)
	}
	return err
}

func sendAndroidMsg(externalId string, body string) error {

	request := push.CreatePushRequest()
	request.Scheme = "https"

	request.AppKey = requests.Integer(config.GetEmasAndroidAppKey())
	request.PushType = "MESSAGE"
	request.DeviceType = "ANDROID"
	request.Target = "ACCOUNT"
	request.TargetValue = externalId
	request.Body = body
	request.Title = body
	//产品决定
	//request.StoreOffline = requests.NewBoolean(true)
	//request.PushTime = "1"
	//默认是72小时
	//request.ExpireTime = time.Now().Add(time.Minute).UTC().Format(time.RFC3339)
	//
	response, err := EmasClient.Push(request)
	if err != nil {
		buf, _ := json.Marshal(response)
		mylogrus.MyLog.Errorf("emas sendAndroidMsg fail err:%v, externalId:%v , body:%v ,response:%#v", err, externalId, body, string(buf))
	} else {
		mylogrus.MyLog.Infof("emas sendAndroidMsg success externalId:%v, body:%v ", externalId, body)
	}
	return err

	//暂时不修改
	/*	requestAndroid := push.CreatePushMessageToAndroidRequest()
		requestAndroid.Scheme = "https"
		requestAndroid.AppKey = requests.Integer(config.GetEmasAndroidAppKey())
		requestAndroid.Target = "ACCOUNT"
		requestAndroid.TargetValue = externalId
		requestAndroid.Body = body
		requestAndroid.Title = body
		response, err := EmasClient.PushMessageToAndroid(requestAndroid)
		if err != nil {
			mylogrus.MyLog.Errorf("emas sendAndroidMsg fail externalId:%v, body:%v , response:%#v", externalId, body, response)
		} else {
			mylogrus.MyLog.Infof("emas sendAndroidMsg success externalId:%v, body:%v", externalId, body)
		}
		return err*/
}

func sendIosMsg(externalId string, body string) error {
	request := push.CreatePushRequest()
	request.Scheme = "https"

	request.AppKey = requests.Integer(config.GetEmasIosAppKey())
	request.PushType = "MESSAGE"
	request.DeviceType = "iOS"
	request.Target = "ACCOUNT"
	request.TargetValue = externalId
	request.Body = body
	request.Title = body
	//request.StoreOffline = requests.NewBoolean(true)
	response, err := EmasClient.Push(request)
	if err != nil {
		buf, _ := json.Marshal(response)
		mylogrus.MyLog.Errorf("emas sendIosMsg fail externalId:%v, err:%v body:%v, response:%#v", externalId, err, body, string(buf))
	} else {
		mylogrus.MyLog.Infof("emas sendIosMsg success externalId:%v body:%v", externalId, body)
	}
	return err
	/*	requestIos := push.CreatePushMessageToiOSRequest()
		requestIos.Scheme = "https"
		requestIos.AppKey = requests.Integer(config.GetEmasIosAppKey())
		requestIos.Target = "ACCOUNT"
		requestIos.TargetValue = externalId
		requestIos.Body = body
		requestIos.Title = body
		response, err := EmasClient.PushMessageToiOS(requestIos)
		if err != nil {
			mylogrus.MyLog.Errorf("emas sendIosMsg fail externalId:%v body:%v response:%#v", externalId, body, response)
		} else {
			mylogrus.MyLog.Infof("emas sendIosMsg success externalId:%v body:%v ", externalId, body)
		}
		return err*/
}

func SendAndroidMsgAll(body string) error {

	request := push.CreatePushRequest()
	request.Scheme = "https"

	request.AppKey = requests.Integer(config.GetEmasAndroidAppKey())
	request.PushType = "MESSAGE"
	request.DeviceType = "ANDROID"
	request.Target = "ALL"
	request.TargetValue = "ALL"
	request.Body = body
	request.Title = body
	//产品决定
	request.StoreOffline = requests.NewBoolean(true)
	//request.PushTime = "1"
	//默认是72小时
	//request.ExpireTime = time.Now().Add(time.Duration(time.Hour * 72)).UTC().Format(time.RFC3339)
	//
	response, err := EmasClient.Push(request)
	if err != nil {
		buf, _ := json.Marshal(response)
		mylogrus.MyLog.Errorf("emas sendAndroidMsgAll fail err:%v body:%v ,response:%#v", err, body, string(buf))
	} else {
		mylogrus.MyLog.Infof("emas sendAndroidMsgAll success body:%v ", body)
	}
	return err

	//暂时不修改
	/*	requestAndroid := push.CreatePushMessageToAndroidRequest()
		requestAndroid.Scheme = "https"
		requestAndroid.AppKey = requests.Integer(config.GetEmasAndroidAppKey())
		requestAndroid.Target = "ALL"
		requestAndroid.TargetValue = "all"
		requestAndroid.Body = body
		requestAndroid.Title = body
		response, err := EmasClient.PushMessageToAndroid(requestAndroid)
		if err != nil {
			mylogrus.MyLog.Errorf("emas sendAndroidMsgAll fail, body:%v err:%v, response:%#v",body, err, response)
		} else {
			mylogrus.MyLog.Infof("emas sendAndroidMsgAll success body:%v", body)
		}
		return err*/
}

func SendIosMsgAll(body string) error {
	request := push.CreatePushRequest()
	request.Scheme = "https"

	request.AppKey = requests.Integer(config.GetEmasIosAppKey())
	request.PushType = "MESSAGE"
	request.DeviceType = "iOS"
	request.Target = "ALL"
	request.TargetValue = "ALL"
	request.Body = body
	request.Title = body
	request.StoreOffline = requests.NewBoolean(true)
	response, err := EmasClient.Push(request)
	if err != nil {
		buf, _ := json.Marshal(response)
		mylogrus.MyLog.Errorf("emas sendIosMsgAll fail err:%v body:%v, response:%#v", err, body, string(buf))
	} else {
		mylogrus.MyLog.Infof("emas sendIosMsgAll success, body:%v", body)
	}
	return err
	/*	requestIos := push.CreatePushMessageToiOSRequest()
		requestIos.Scheme = "https"
		requestIos.AppKey = requests.Integer(config.GetEmasIosAppKey())
		requestIos.Target = "ALL"
		requestIos.TargetValue = "all"
		requestIos.Body = body
		requestIos.Title = body
		response, err := EmasClient.PushMessageToiOS(requestIos)
		if err != nil {
			mylogrus.MyLog.Errorf("emas sendIosMsgAll fail, body:%v, err:%v, response:%#v", body, err, response)
		} else {
			mylogrus.MyLog.Infof("emas sendIosMsgAll, success, body:%v", body)
		}
		return err*/
}

func QueryPushStatByMsg(messageId string) (push.PushStats, error) {
	request := push.CreateQueryPushStatByMsgRequest()
	request.Scheme = "https"
	request.AppKey = requests.Integer(config.GetEmasIosAppKey())
	request.MessageId = requests.Integer(messageId)
	response, err := EmasClient.QueryPushStatByMsg(request)
	if err != nil {
		buf, _ := json.Marshal(response)
		mylogrus.MyLog.Errorf("emas QueryPushStatByMsg fail err:%v messageId:%v, response:%#v", err, messageId, string(buf))
		return push.PushStats{}, err
	}
	return response.PushStats, nil
}

func init() {
	var err error
	EmasClient, err = push.NewClientWithAccessKey(config.GetEmasRegionId(), config.GetEmasAccessKeyId(), config.GetEmasAccessKeySecret())
	if err != nil {
		mylogrus.MyLog.Fatal(err)
	}
}