{"id":2495,"date":"2024-12-30T15:38:57","date_gmt":"2024-12-30T07:38:57","guid":{"rendered":"https:\/\/www.xfan.top\/?p=2495"},"modified":"2024-12-30T15:38:57","modified_gmt":"2024-12-30T07:38:57","slug":"vivo%e6%8e%a8%e9%80%81%e6%9c%8d%e5%8a%a1%e6%b3%a8%e5%86%8c%e5%b0%8f%e5%9d%91","status":"publish","type":"post","link":"https:\/\/www.xfan.top\/index.php\/2024\/12\/30\/2495\/","title":{"rendered":"vivo\u63a8\u9001\u670d\u52a1\u6ce8\u518c\u5c0f\u5751"},"content":{"rendered":"<p>\u4f7f\u7528vivo\u63a8\u9001\u670d\u52a1SDK\u65f6\uff0c\u5fc5\u987b\u5728turnOnPush\u6210\u529f\u540e\u518dgetRegId\uff0c\u5426\u5219\u62ff\u5230regId\u7684\u4e3anull<\/p>\n<p>\u5e94\u8be5\u5728turnOnPush\u7684IPushActionListener.onStateChanged\u65b9\u6cd5\u4e2d\u6216\u88ab\u8c03\u7528\u4e4b\u540e\u518dgetRegId<\/p>\n<pre><code>import com.vivo.push.IPushActionListener;\nimport com.vivo.push.PushClient;\nimport com.vivo.push.PushConfig;\nimport com.vivo.push.util.VivoPushException;\n\npublic class VivoPushService {\n\n    public VivoPushService() {\n\n        try {\n            PushConfig config = new PushConfig.Builder().agreePrivacyStatement(true).build();\n            PushClient.getInstance(MyApplication.myApplicationContext).initialize(config);\n        } catch (VivoPushException e) {\n            LogUtils.LogD(&quot;\u6b64\u5904\u5f02\u5e38\u8bf4\u660e\u662f\u6709\u5fc5\u987b\u7684vpush\u914d\u7f6e\u672a\u914d\u7f6e\u6240\u81f4\uff0c\u9700\u8981\u4ed4\u7ec6\u68c0\u67e5\u96c6\u6210\u6307\u5357\u7684\u5404\u9879\u914d\u7f6e&quot;);\n            e.printStackTrace();\n        }\n\n        \/\/ \u6253\u5f00push\u5f00\u5173, \u5173\u95ed\u4e3aturnOffPush\uff0c\u8be6\u89c1api\u63a5\u5165\u6587\u6863\n        PushClient.getInstance(MyApplication.myApplicationContext).turnOnPush(new IPushActionListener() {\n            @Override\n            public void onStateChanged(int state) {\n                \/\/ TODO: \u5f00\u5173\u72b6\u6001\u5904\u7406\uff0c 0\u4ee3\u8868\u6210\u529f\uff0c\u83b7\u53d6regid\u5efa\u8bae\u5728state=0\u540e\u83b7\u53d6\uff1b\n                if (state == 0) {\n                    PushClient.getInstance(MyApplication.myApplicationContext).getRegId(new VivoMsgCallbackService());\n                }\n            }\n        });\n        \/\/ \u82e5\u4e0d\u5728push\u5f00\u5173\u6253\u5f00\u540e\u83b7\u53d6push token\u4e3anull\n        \/\/ PushClient.getInstance(MyApplication.myApplicationContext).getRegId(new VivoMsgCallbackService());\n    }\n}\n<\/code><\/pre>\n<pre><code>\nimport android.text.TextUtils;\n\nimport com.vivo.push.listener.IPushQueryActionListener;\n\npublic class VivoMsgCallbackService implements IPushQueryActionListener {\n\n    @Override\n    public void onSuccess(String regid) {\n        if (TextUtils.isEmpty(regid)) {\n            LogUtils.LogD(&quot;vivo push service RegisterID is null: &quot;);\n        } else {\n            LogUtils.LogD(&quot;vivo push service RegisterID: &quot; + regid);\n            \/\/ \u62ff\u5230RegisterID\n        }\n    }\n\n    @Override\n    public void onFail(Integer integer) {\n        LogUtils.LogD(&quot;vivo push service Register failed: &quot; + integer.toString());\n\n    }\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528vivo\u63a8\u9001\u670d\u52a1SDK\u65f6\uff0c\u5fc5\u987b\u5728turnOnPush\u6210\u529f\u540e\u518dgetRegId\uff0c\u5426\u5219\u62ff\u5230regId\u7684\u4e3anul [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2495","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/posts\/2495","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/comments?post=2495"}],"version-history":[{"count":2,"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/posts\/2495\/revisions"}],"predecessor-version":[{"id":2522,"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/posts\/2495\/revisions\/2522"}],"wp:attachment":[{"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/media?parent=2495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/categories?post=2495"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xfan.top\/index.php\/wp-json\/wp\/v2\/tags?post=2495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}