In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about how java integrates Xiaomi push service. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
Integrate Xiaomi push service
The official documents of this kind of push are generally more detailed. If you want to know more about it, it is recommended to see the official documents.
Official document address: https://dev.mi.com/console/appservice/push.html
Some preparations need to be made before formal development.
1. Developers need to log in to the developer's website to enter the push service (apply for AppID, AppKey, AppSecret)
2. Visit the developer's website to download SDK
Extract the downloaded SDK and drop the 2 dependent jar packages in the folder into the libs directory of the project project.
The next step is to send a message.
/ / when using Push service in formal environment, you need to call the following code Constants.useOfficial () when starting; / / when using Push service in test environment, you need to call the following code / / Constants.useSandbox (); Sender sender = new Sender (AppSecret); String messagePayload = "message body content"; String title = "message title" Message message = new Message.Builder () / / compiled message body .title (title) / / sets the title of the notification displayed in the notification bar. Description (description) / / sets the description of the notification displayed in the notification bar. Payload (messagePayload) / / sets the content of the message to be sent. UplotedPackageName (PackageName) / / set the package name packageName of app PackageName must be consistent with the result of the application on the developer's website.passThrough (0) / sets whether the message is transmitted to App through, 1 indicates transparent message, 0 indicates notification bar message (default is notification bar message) .notifyId (notifyId) / / optional. By default, the notification bar only displays a push message. If the notification bar is to display multiple push messages, you need to set different notify_id .notifyType (- 1) / / notification types for different messages. The type type supports the following values: 1: use default tone prompt 2: use default vibration prompt 4: use default led light prompt-1 (system default): all three effects have 0: none of the above three effects That is, silent push. / / the following extra configuration can be customized to open the mobile phone app specification page (Activity) .upload (Constants.EXTRA_PARAM_NOTIFY_EFFECT, Constants.NOTIFY_ACTIVITY) .build (Constants.EXTRA_PARAM_INTENT_URI, "intent configuration requires app developers to compile for you") .build (); Result result = sender.send (message, regId, 3) / / according to regID, the message is sent to the specified device, and the last parameter does not retry LOGGER.info ("Xiaomi push-> > return result Result: {}", JSON.toJSONString (result)). This is how the java shared by Xiaobian integrates Xiaomi push service. If you happen to have similar doubts, please refer to the above analysis for understanding. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.