1

I created a hello world project on cordova 3.4.0 for android. Somehow my dialogs/notifications plugin does not work correctly. I added the plugin like this

cordova plugin add org.apache.cordova.dialogs

and added this line in my android manifest:

<uses-permission android:name="android.permission.VIBRATE" />

When I tested the plugin it worked really good with it's methods "alert", "prompt", "confirm" and "beep", but as soon as I want to call the vibrate method like I read in the Cordova API it crashes. Here is my code:

$(document).ready(function(){
   document.addEventListener("deviceready", function() {
      navigator.notification.vibrate(1000);
   }, false);
})

I run into this error message in the logcat:

Uncaught TypeError: Object #<Object> has no method 'vibrate'

I logged out all methods of navigator.notification like this:

var res = [];
for(var m in navigator.notification) {
     if(typeof navigator.notification[m] == "function") {
        res.push(m)
     }
}
console.log(res);

The Result: "alert,confirm,prompt,beep,activityStart,activityStop,progressStart,progressStop,progressValue"

Does anyone have an idea why there is no vibrate method in navigator.notification ?

EDIT

I have got this entry in my res/config.xml:

<feature name="Notification">
    <param name="android-package" value="org.apache.cordova.dialogs.Notification" />
</feature>

Using Microdata's 'itemprop' attribute on non-text elements

I have a following piece of HTML with some Schema.org Microdata added:

<section class="feature" itemprop="description">
    <div class="measure">
      <p>Lorem ipsum etc...</p>
      <p>Lorem ipsum etc...</p>

      <figure class="polaroid product">
        <img src="dry-aged-beef-horizontal.jpg", alt="Dry Aged Beef", itemprop="image" />
        <figcaption>Dry Aged Beef</figcaption>
      </figure>
    </div>
  </section>

Is it all right to use the itemprop attribute on an element that isn't itself a text node (like section above), but contains child elements that are?

Looking at the official Schema.org examples one could become suspicious that only text elements can be tagged with Microdata attributes:

<span itemprop="description">0.7 cubic feet countertop microwave.   Has six preset cooking categories and convenience features like   Add-A-Minute and Child Lock.</span>

Also, my product description consists of more paragraphs than one, so again setting the itemprop tag on a parent element makes all the sense. Is this correct Microdata/Schema.org though?

4

2 回答 2

2

For some reason vibration isn't included in the notification plugin anymore but in an extra plugin instead:

https://github.com/apache/cordova-plugin-vibration/blob/master/doc/index.md

于 2014-06-16T11:31:18.040 回答
1

将通知功能添加到您的 config.xml:

<feature name="Notification">
    <param name="android-package" value="org.apache.cordova.Notification" />
</feature>
于 2014-06-16T10:54:27.563 回答