<script type="text/javascript"> var message = new blackberry.message.Message(); message.toRecipients = "noone@blackberryWidgets.com"; message.subject = "Hello"; message.body = "World"; message.send(); </script>
Unfortunately it cannot be used for send PIN message using PIN address.
I'm adding some code to provide send message using PIN address.
<script type="text/javascript"> var message = new blackberry.message.Message(); message.toRecipients = "28C427ED"; // Using PIN ADDRESS instead of email message.subject = "Hello"; message.body = "World"; message.send(); </script>
You will need to modify your code on your BlackBerry WebWorks SDK Installations
For example below is your installation folder for BlackBerry WebWorks SDK
C:\Program Files (x86)\Research In Motion\BlackBerry WebWorks SDK 2.2.0.15
- ext
- blackberry.messaging
- blackberry
- messaging
- message
- MessageUtility.java // you will need modify this class
MessageUtility.java
Add new import
import net.rim.blackberry.api.mail.PINAddress;
Add new static method
/** * Check whether the address given is PIN address. * PIN Address is in hexadecimal format [ 0-9, A-F ] * * @param address address to be check * @return true when the address is a PIN address */ public static boolean isPIN ( String address ) { char[] check = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; if(address.length()!=8) return false; for(int i=0;i<address.length();i++){ boolean pass = false; for(int j=0;j<check.length;j++){ if(address.charAt(i)==check[j]){ pass = true; break; } } if(!pass) return false; } return true; }
Modify existing method stringToAddresses
/**
* Convert String addresses to an array of Address objects.
*
* @param addressString
* @return an array of Address objects
*/
public static Address[] stringToAddresses( String addressString ) {
String[] emails = MessageUtility.split( addressString );
Address[] addresses = new Address[ emails.length ];
for( int i = 0; i < emails.length; i++ ) {
try {
if(MessageUtility.isPIN (emails[i])){
addresses[ i ] = new PINAddress( emails[ i ], emails[ i ]);
} else {
addresses[ i ] = new Address( emails[ i ], emails[ i ] );
}
} catch( AddressException e ) {
addresses[ i ] = null;
}
}
return addresses;
}
Now you can build your BlackBerry WebWorks application using bbwp command
Find how to build webworks application here https://bdsc.webapps.blackberry.com/html5/
No comments:
Post a Comment