小编Gan*_*esh的帖子

Firebase 网络推送通知,点击无效

自从我试图完成它以来的几天,但我完全被困在这一点上。

这是我的服务工作者文件中的代码

importScripts('https://www.gstatic.com/firebasejs/6.0.2/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/6.0.2/firebase-messaging.js');

firebase.initializeApp({
    messagingSenderId: "xxxxxxxxxxxx"
});

var messaging = firebase.messaging();


messaging.setBackgroundMessageHandler(function(payload) {

    console.log('[firebase-messaging-sw.js] Received background message ', payload);
    // Customize notification here
    var notificationTitle = payload.data.title; //or payload.notification or whatever your payload is
    var notificationOptions = {
      body: payload.data.body,
      icon: payload.data.icon,
      image: payload.data.image,

      data: { url:payload.data.openURL }, //the url which we gonna use later
      actions: [{action: "open_url", title: "View"}]
    };

    return event.waitUntil(self.registration.showNotification(notificationTitle,
      notificationOptions));
});

 self.addEventListener('notificationclick', function(event) {


    console.log('event = ',event);
    event.notification.close();
    event.waitUntil(clients.openWindow(event.notification.data.url));

    switch(event.action){
      case 'open_url':
        window.open(event.notification.data.url);
      break;
      case …
Run Code Online (Sandbox Code Playgroud)

javascript push-notification firebase service-worker firebase-cloud-messaging

7
推荐指数
1
解决办法
3499
查看次数

未捕获的类型错误:无法读取未定义的属性“getJSON”

我正在自定义 wordpress 主题,为什么在尝试在搜索框的输入字段中键入时出现此错误,我的 html 代码是

<div class="mysearchdiv">
<input type="" name="" class="mysearch">
<ul class="skills-list" id="skills_list"></ul>
</div>
Run Code Online (Sandbox Code Playgroud)

和backbone.js 代码是

jQuery(document).ready(function(){
    var mymodel= Backbone.Model.extend({
        defaults:function(){
            return{
            name:''
            }
        }
    });

    var mycollection=Backbone.Collection.extend({
        model:mymodel
    });
    var mynewcollection= new mycollection();
    var myview=Backbone.View.extend({
        model:mynewcollection,
        el:'.mysearchdiv',
        events:{
            'keypress .mysearch':'search'
        },
        initialize:function(){
            console.log("init");
            var view=this;
            this.skill_list=this.$('ul.skill-list');
            view.skills={};
            this.$el.find('input.mysearch').typeahead({
                minLength:0,
                items:10,
                source: function(query, process) {
                    console.log("Skill_Control typeahead source");
                    console.log(query);
                    console.log(process);
                    console.log(ae_globals.ajaxURL);
                    if (view.skills.length > 0) return view.skills;
//getting error at this point
//where ae_globals.ajaxURL is ajax url in wp …
Run Code Online (Sandbox Code Playgroud)

ajax wordpress jquery backbone.js backbone-views

1
推荐指数
1
解决办法
5699
查看次数