草庐IT

push-notification

全部标签

Javascript:.push 不是函数

我的代码有问题:vararrays=[[1,2,3],[4,5],[6]];console.log(reduce(arrays,function(array,b){returnarray.push(b);}));functionreduce(array,combine){varcurrent=[];for(vari=0;i我收到这个错误:TypeError:array.pushisnotafunction(line3)据我了解,这是因为它将数组参数视为数组以外的东西。但是,我想我给它提供了一个数组变量“current”。有人可以解释这个问题吗?谢谢。 最佳答

javascript - 获取 PushManager 订阅时出错 - JavaScript

我有以下代码注册了一个serviceworker并要求用户允许通知。在用户允许serviceWorkerRegistration.pushManager.getSubscription()返回的promise为null的推送通知后,我收到错误消息。当我关闭浏览器并再次强制调用此函数时,它可以正常工作。我不明白为什么。这是我的代码:window.vapidPublicKey=newUint8Array([4,45,...]);if(navigator.serviceWorker){navigator.serviceWorker.register('/serviceworker.js').

javascript - 应用程序被杀死时不会触发 onNotification()

我正在使用https://github.com/zo0r/react-native-push-notification获取推送通知,当应用程序处于Active时,onNotification正在按方面工作或在Background我收到了通知,但是当我终止应用程序时,我只收到通知并且没有触发onNotification任何人都可以帮助我寻找解决方案但是没有任何效果,我在触发onNotification时增加了Android徽章的数量有没有另一种方法可以在应用程序被终止时增加Android徽章?"react-native":"0.55.3","react-native-push-notif

javascript - 服务人员 : async await in combination with waituntil is not working properly

在使用async/await语法时,我正在为serviceworker中的promises而苦苦挣扎。以下情况:我收到推送通知,想处理点击事件。如果我将“旧”语法与then和catch一起使用,我可以遍历客户端列表并对其执行一些操作。如果我对async/await使用我喜欢的方式,它不会做任何事情。self.addEventListener("notificationclick",event=>{//isworkingevent.waitUntil(self.clients.matchAll().then(clientList=>{console.log(clientList);}))

javascript - 为什么要用 array.push() 来做一个对象?

我正在阅读HowcanIgetquerystringvaluesinJavaScript?在Stackoverflow上,第一个回复中的这段代码让我想知道为什么要这样使用“vars.push()”?functiongetUrlVars(){varvars=[],hash;varhashes=window.location.href.slice(window.location.href.indexOf('?')+1).split('&');for(vari=0;i但不是这样的:varvars=[];...vars.push(hash[0]);vars[hash[0]]=hash[1];我

javascript - Angular : Push item to list doesn't update the view

当我将项目推送到数组时,View不会刷新列表。表格:{{product.Code}}{{product.Name}}形式:Code:Naam:在Controller中提交产品:$scope.submitProduct=function(){console.log('before:'+$scope.products.length);$scope.products.push({Code:$scope.product.Code,Name:$scope.product.Name});console.log('after:'+$scope.products.length);console.log

javascript - TypeError : value. push is not a function with Angularjs $resource 查询

我从服务器返回一个对象数组:[{id:1,name:"name"},{id:2,name:"name2"}]现在我使用angular-resource$query来获取数据,因为它需要一个数组。收到数据后出现此错误:TypeError:value.pushisnotafunction我从server=给出的响应有问题吗?错误来源://jshint+W018if(action.isArray){value.length=0;forEach(data,function(item){if(typeofitem==="object"){value.push(newResource(item))

javascript - 类型错误 : Cannot read property 'push' of undefined, JavaScript

我在这个Angular项目中工作,用户在该项目中提交评论表单,新评论会添加到已发布的评论中。这是我的代码。.controller('productCtrl',function($scope,$http,$routeParams,Page){$scope.product={};$scope.review={};$scope.comments={};routeparm=$routeParams.param;$scope.review=function(){varreview_box=$scope.review_form.review_box;$http.post('./comment.ph

javascript - 如何对Web Push做特征检测?

是否有任何简单的方法可以在浏览器(桌面和移动设备)中检测WebPushAPI的特性 最佳答案 有些浏览器版本只支持serviceworker,不支持PushAPI。建议您尝试检测PushAPI本身。如果您需要以同步方式(即不等待Promise)检查浏览器支持,您可以使用这个(从PushpadSDK复制):functionisPushApiSupported(){return'PushManager'inwindow;} 关于javascript-如何对WebPush做特征检测?,我们在S

javascript - pushState/popstate 的奇怪问题 - 初始页面似乎是 "pushed"两次

我遇到了一个关于pushState/popstate的奇怪问题,我的初始页面似乎被保存了两次。如果没有例子,有点难以解释。像这样:当前页面是www.bing.com将我的URL复制/粘贴到URL栏并加载页面点击页面上的链接(此链接会触发AJAX请求,然后操作DOM以显示检索到的数据。)按后退按钮将我带到与步骤2相同的页面再次按下后退按钮,但我仍然在与步骤2/4相同的页面上再次按后退按钮,我会回到www.bing.com如您所见,我需要按两次后退按钮才能返回www.bing.com,而它应该只需要按1次。我的页面的简短说明(代码在页面底部):当页面加载时,下拉选择的初始列表通过AJAX检