javascript原型:为什么这不起作用?(javascript prototyping: why doesn't this work?)
我正在尝试下面的代码:
var classA = function() {}; classA.prototype = { x: 4, y: 6 }; classA.prototype.prototype = { z: 10 }; var foo = new classA(); alert(foo.z);
为什么警报恢复为未定义? JavaScript不应该遵循原型链来找到z?
I'm looking at trying the following code:
var classA = function() {}; classA.prototype = { x: 4, y: 6 }; classA.prototype.prototype = { z: 10 }; var foo = new classA(); alert(foo.z);
Why does the alert come back as undefined? Shouldn't javascript follow the prototype chain to find z?
原文:https://stackoverflow.com/questions/5794240
更新时间:2020-12-13 08:12
最满意答案
将此行添加到
messaging.setBackgroundMessageHandler
事件可以解决此问题:self.registration.hideNotification();
这样,默认通知将不会显示,您必须在
self.addEventListener
事件中显示您的通知。The problem can be solved with adding this line to the
messaging.setBackgroundMessageHandler
event:self.registration.hideNotification();
This way, the default notification won't show and you have to show your notification in the
self.addEventListener
event.
相关问答
更多-
无声推送只有在第二次推送到达时才能正常工作(应用程序在后台)(Silent push only work properly when second push arrive (app in background))[2022-04-05]
当您完成参加通知时,您必须调用completionHandler(),但您立即调用它。 你最好在mqttDidReceive和错误委托方法中调用它。 You have to call completionHandler() when you finish attending the notification, but you are calling it immediately. You'd better callint it in mqttDidReceive and in the error deleg ... -
在内部方法didRegisterForRemoteNotificationsWithDeviceToken中 ,添加以下代码: func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) { let tokenChars = UnsafePointer
(deviceToken.bytes) var tokenS ... -
如果浏览器处于后台,则FCM推送通知会两次到达(FCM Push notifications arrive twice if the browser is in background)[2023-12-08]
将此行添加到messaging.setBackgroundMessageHandler事件可以解决此问题: self.registration.hideNotification(); 这样,默认通知将不会显示,您必须在self.addEventListener事件中显示您的通知。 The problem can be solved with adding this line to the messaging.setBackgroundMessageHandler event: self.registrat ... -
你有活跃的背景模式吗? 看看这个 Did you active background mode? Look this
-
1.Google建议使用GCMReceiver而不是WakefulBroadcastReceiver 2.您必须使用GcmListenerService扩展您的服务 3.另外,我们必须使用InstanceId ,因为不推荐使用gcm.register()(它仍会生成gcm键)。 https://developers.google.com/cloud-messaging/android/client 他们的使用示例代码“ https://github.com/google/gcm ” 一周前我遇到了类似问题, ...
-
通常推送通知确实很快到达。 但是有一些罕见的情况,我们看到他们被推迟了: Android设备上的通知延迟: 一些家庭和商用wifi路由器将导致设备与Google GCM服务器的连接关闭。 设备稍后重新打开连接并接收延迟的通知。 (这里讨论: https ://groups.google.com/forum/#! topic/ android-gcm/ Y33c9ib54jY ) 某些自定义版本的Android操作系统具有省电设置,可能会导致通知延迟或忽略。 例如,索尼Xperia设备具有“耐力模式”。 (这 ...
-
您需要使用JavaScript Fetch API,AJAX,长轮询,WebSockets或SSE。 在客户端获得通知后,您可以使用vanilla Javascript和Notification API来显示通知。 You need to use the Javascript Fetch API, AJAX, Long Polling, WebSockets or SSE. Once you get the notification on the client side you can use vanill ...
-
是的,应用程序可以并且确实接收推送通知,无论它们是后台还是不活动。 在您的applicationDidEnterBackground:方法中,您可以检查您的应用是否收到了通知,然后从那里处理。 Yes, applications can and do receive Push Notifications whether they are backgrounded or not even active. In your applicationDidEnterBackground: method you can ...
-
如何使用FCM使用PHP脚本向多个设备发送推送通知?(How to send push notifications to multiple devices using php script using FCM?)[2023-09-11]
尝试将多个设备的设备ID作为阵列发送。 在你的情况下, $ registration_ids必须是设备ID的数组。 例如 $registration_ids = array('Device ID 1', 'Device ID 2'); Try to send device ID of multiple devices as an array. In your case, $registration_ids must be an array of device IDs. E.g $registration_ ... -
从推送通知(FCM)获取数据,而无需单击通知(Get data from push notification (FCM) without do click in notification)[2022-06-30]
如果应用程序处于后台状态,则UINotification称为应用程序 didReceiveRemoteNotification,如果应用程序处于打开状态UINotification,则称为application:didFinishLaunchingWithOptions ,并且无法在未单击iOS中的通知的情况下获取数据。 If the app is in background state UINotification called application didReceiveRemoteNotificati ...