欧阳氏 84c068783d
新增 firebase cloud message 消息推送 (#236)
* 新增 firebase cloud message 消息推送

新增 api接口  /third/fcm_update_token 用于更新客户端获取到 FCM token 同步到服务器

* mongodb授权缺少授权数据库

windows下面的编译+启动
2022-07-25 17:07:47 +08:00

55 lines
1.3 KiB
Go

/*
** description("").
** copyright('open-im,www.open-im.io').
** author("fg,Gordon@open-im.io").
** time(2021/3/22 15:33).
*/
package logic
import (
pusher "Open_IM/internal/push"
fcm "Open_IM/internal/push/fcm"
"Open_IM/internal/push/getui"
jpush "Open_IM/internal/push/jpush"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/kafka"
"Open_IM/pkg/statistics"
"fmt"
)
var (
rpcServer RPCServer
pushCh PushConsumerHandler
pushTerminal []int32
producer *kafka.Producer
offlinePusher pusher.OfflinePusher
successCount uint64
)
func Init(rpcPort int) {
rpcServer.Init(rpcPort)
pushCh.Init()
pushTerminal = []int32{constant.IOSPlatformID, constant.AndroidPlatformID}
}
func init() {
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.Ws2mschat.Topic)
statistics.NewStatistics(&successCount, config.Config.ModuleName.PushName, fmt.Sprintf("%d second push to msg_gateway count", constant.StatisticsTimeInterval), constant.StatisticsTimeInterval)
if config.Config.Push.Getui.Enable {
offlinePusher = getui.GetuiClient
}
if config.Config.Push.Jpns.Enable {
offlinePusher = jpush.JPushClient
}
if config.Config.Push.Fcm.Enable {
offlinePusher = fcm.FcmClient
}
}
func Run() {
go rpcServer.run()
go pushCh.pushConsumerGroup.RegisterHandleAndConsumer(&pushCh)
}