我正在尝试将数据从我的服务器发送到FCM,以便它可以显示在我的网页的特定部分。它就像股票应用程序,例如,数据不断更新。我试图实现同样的方式。到目前为止,我已将其配置为从FCM接收数据并正在接收。但问题是它显示了喜欢的通知。我的同事正在进行同样的工作,可以选择只将数据发送到Android应用程序并隐藏要显示的通知。同样,我想在网上听到,但我无法做到。
(function () {
// Initialize Firebase
var config = {
apiKey: "xxxxxxxxxxxxxx",
authDomain: "test-xxxxxxxx.xxxxxxxx.com",
databaseURL: "https://xxxxxx-xxxxxxxx.firebaseio.com",
projectId: "xxx-469e9",
storageBucket: "",
messagingSenderId: "xxxxxx"
};
firebase.initializeApp(config);
// Retrieve Firebase Messaging object.
const messaging = firebase.messaging();
messaging.requestPermission()
.then(function() {
console.log('Notification permission granted.');
return messaging.getToken();
})
.then(function(token) {
console.log(token);
})
.catch(function(err) {
console.log('Unable to get permission to notify.', err);
})
messaging.onMessage(function(payload) {
console.log("Message received. ", payload);
// ...
});
}());
on firebase-messaging-sw.js
importScripts('https://www.gstatic.com/firebasejs/4.3.1/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/4.3.1/firebase-messaging.js');
// Initialize Firebase
var config = {
apiKey: "xxxxxx",
authDomain: "xxxx-xxxxxxxxxx.com",
databaseURL: "https://xxx-xxx.firebaseio.com",
projectId: "xxxx-xxxxxxxxxx",
storageBucket: "",
messagingSenderId: "xxxxxxxxxxxx"
};
firebase.initializeApp(config);
const messaging = firebase.messaging();
答案 0 :(得分:1)
黑客可能会在...之后立即关闭通知
<GridLayout class="template_body" rows="40,*,60">
<StackLayout row="0" [visibility]="isTablet ? 'visible' : 'collapsed'">
<Label text="Drag statements to the proper category."></Label>
<FlexboxLayout flexDirection="row" row="1" [visibility]="isSubmitted ? 'visible' : 'collapsed'">
<AbsoluteLayout height="10" width="10" class="correct-legend"></AbsoluteLayout><Label class="legend-label" text="Correct"></Label>
<AbsoluteLayout height="10" width="10" class="incorrect-legend"></AbsoluteLayout><Label class="legend-label" text="Incorrect"></Label>
</FlexboxLayout>
</StackLayout>
realPush参数当然是由您自己管理的