demo 使用插件的hbuild例子,然后把首页改成这个就行 如果不行需要填写appid配置
<template>
<view class="button-sp-area">
<view>
点击创建通知,会创建一个通知
然后点击重启手机,再点击创建通知无效
</view>
<button type="primary" plain="true" @click="onCreateMsg">创建通知</button>
<button type="primary" plain="true" @click="onReload">注册通知并且重启</button>
</view>
</template>
<script>
const modal = uni.requireNativePlugin('modal');
const aliyunPush = uni.requireNativePlugin('Aliyun-Push');
const aliyunThirdPush = uni.requireNativePlugin('Aliyun-ThirdPush');
const channel = uni.requireNativePlugin('Aliyun-Push-NotificationChannel');
export default {
data() {
return {
title: '',
account: '',
alias: '',
tag: '',
phone: '',
}
},
methods: {
onCreateMsg() {
plus.push.createMessage('xxxxxxxxxxxx')
},
onReload() {
// 注册通知后再重启
this.register()
this.registerLog()
this.registerThirdPush()
setTimeout(() => {
plus.runtime.restart()
}, 3000)
},
registerLog() {
console.log("call register log");
aliyunPush.registerLog({}, result => {
console.warn("push plugin log : " + result);
});
aliyunThirdPush.registerLog({}, result => {
console.warn("third push plugin log : " + result);
})
},
register() {
console.log("call register push");
aliyunPush.registerPush({}, result => {
const event = result.event;
if (event === 'registerPush') {
console.log('注册')
} else {
const data = JSON.stringify(result.data);
console.log("receive push event : " + event);
console.log("receive push data : " + data);
}
});
},
registerThirdPush() {
console.log("call registerThirdPush");
aliyunThirdPush.registerThirdPush({}, result => {
const data = JSON.stringify(result);
console.log("receive third push : " + data);
modal.toast({
message: data,
duration: 5
});
});
},
}
}
</script>
2 个回复
1***@qq.com (作者) - 1111
demo 使用插件的hbuild例子,然后把首页改成这个就行 如果不行需要填写appid配置
<template>
<view class="button-sp-area">
<view>
点击创建通知,会创建一个通知
然后点击重启手机,再点击创建通知无效
</view>
<button type="primary" plain="true" @click="onCreateMsg">创建通知</button>
<button type="primary" plain="true" @click="onReload">注册通知并且重启</button>
</view>
</template>
<script>
const modal = uni.requireNativePlugin('modal');
const aliyunPush = uni.requireNativePlugin('Aliyun-Push');
const aliyunThirdPush = uni.requireNativePlugin('Aliyun-ThirdPush');
const channel = uni.requireNativePlugin('Aliyun-Push-NotificationChannel');
export default {
data() {
return {
title: '',
account: '',
alias: '',
tag: '',
phone: '',
}
},
methods: {
onCreateMsg() {
plus.push.createMessage('xxxxxxxxxxxx')
},
onReload() {
// 注册通知后再重启
this.register()
this.registerLog()
this.registerThirdPush()
setTimeout(() => {
plus.runtime.restart()
}, 3000)
},
registerLog() {
console.log("call register log");
aliyunPush.registerLog({}, result => {
console.warn("push plugin log : " + result);
});
aliyunThirdPush.registerLog({}, result => {
console.warn("third push plugin log : " + result);
})
},
register() {
console.log("call register push");
aliyunPush.registerPush({}, result => {
const event = result.event;
if (event === 'registerPush') {
console.log('注册')
} else {
const data = JSON.stringify(result.data);
console.log("receive push event : " + event);
console.log("receive push data : " + data);
}
});
},
registerThirdPush() {
console.log("call registerThirdPush");
aliyunThirdPush.registerThirdPush({}, result => {
const data = JSON.stringify(result);
console.log("receive third push : " + data);
modal.toast({
message: data,
duration: 5
});
});
},
</script>
阿里云EMAS
我本地测试了一下,不管有没有阿里云推送的插件,此问题均存在。
官方那边有说 为什么影响了吗?
1***@qq.com (作者)
没有插件我试了试不会的
2022-08-29 13:33