本文整理汇总了Golang中github.com/mattermost/platform/model.PushNotification.ContentAvailable方法的典型用法代码示例。如果您正苦于以下问题:Golang PushNotification.ContentAvailable方法的具体用法?Golang PushNotification.ContentAvailable怎么用?Golang PushNotification.ContentAvailable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/mattermost/platform/model.PushNotification
的用法示例。
在下文中一共展示了PushNotification.ContentAvailable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ClearPushNotification
func ClearPushNotification(userId string, channelId string) *model.AppError {
sessions, err := getMobileAppSessions(userId)
if err != nil {
return err
}
msg := model.PushNotification{}
msg.Type = model.PUSH_TYPE_CLEAR
msg.ChannelId = channelId
msg.ContentAvailable = 0
if badge := <-Srv.Store.User().GetUnreadCount(userId); badge.Err != nil {
msg.Badge = 0
l4g.Error(utils.T("store.sql_user.get_unread_count.app_error"), userId, badge.Err)
} else {
msg.Badge = int(badge.Data.(int64))
}
l4g.Debug(utils.T("api.post.send_notifications_and_forget.clear_push_notification.debug"), msg.DeviceId, msg.ChannelId)
for _, session := range sessions {
tmpMessage := *model.PushNotificationFromJson(strings.NewReader(msg.ToJson()))
tmpMessage.SetDeviceIdAndPlatform(session.DeviceId)
if err := sendToPushProxy(tmpMessage); err != nil {
return err
}
}
return nil
}
示例2: clearPushNotification
func clearPushNotification(userId string, channelId string) {
session := getMobileAppSession(userId)
if session == nil {
return
}
msg := model.PushNotification{}
msg.Type = model.PUSH_TYPE_CLEAR
msg.ChannelId = channelId
msg.ContentAvailable = 0
if badge := <-Srv.Store.User().GetUnreadCount(userId); badge.Err != nil {
msg.Badge = 0
l4g.Error(utils.T("store.sql_user.get_unread_count.app_error"), userId, badge.Err)
} else {
msg.Badge = int(badge.Data.(int64))
}
msg.SetDeviceIdAndPlatform(session.DeviceId)
l4g.Debug(utils.T("api.post.send_notifications_and_forget.clear_push_notification.debug"), msg.DeviceId, msg.ChannelId)
sendToPushProxy(msg)
}