Hi, everyone.I would like to send Push notification when Beacon is detected using JavaScript.
Push notification cannot be sent to NCMB after Beacon detection.Here are some of the sources:
Do you have any good samples?
(Actually, I want to send Push notification when I become Near.)
Thank you for your cooperation.
degate.didRangeBeaconsInRegion=function(pluginResult){
var reg = pluginResult.region;
varbeac=pluginResult.beacons;
for(i=0;i<beac.length;i=i+1){
if(beac[i]!=null){
console.log (beac[i].proximity);
NCMB.Push.send(
{
"deliveryTime": {"__type": "Date", "iso": "2013-09-31T17:41:09.106Z"},
"immediateDeliveryFlag": true,
"target": ['ios',
"message": "Hello! World!"
"dialog": true,
"richUrl": "http://www.nifty.com"
},
{
success: function() {
console.log('success');
// success
},
error: function(error) {
// error
console.log('Failed');
}
});
}
}
};
I started ibeacon recently, but it's troublesome that I have to build it every time I test it...
I was just thinking of adding records to NCMB's datastore when I was within Near range.
https://github.com/divineprog/evo-demos/blob/master/Demos2014/iBeaconDemo/app.js
Can you refer to the 119th line of this page?
If there is any progress, please let me know what kind of code you chose.
I have solved it.
Cause)
The ncmb-latest.min.js file in the js folder was missing.This file appears to be generated when you add Nifty MB to the Cordova plug-in.
Here's a sample source (partial excerpt)
degate.didRangeBeaconsInRegion=function(pluginResult){
var reg = pluginResult.region;
varbeac=pluginResult.beacons;
for(i=0;i<beac.length;i=i+1){
if(beac[i]!=null){
console.log (beac[i].proximity);
NCMB.initialize("API key, "client key";
NCMB.Push.send(
{
"immediateDeliveryFlag": true,
"target": ['ios',
"message": "Hello! Tony!!",
"richUrl": "http://www.nifty.com",
},
{
success: function() {
console.log('success');
// success
},
error: function(error) {
// error
console.log('Failed');
}
});
}
}
};
© 2024 OneMinuteCode. All rights reserved.