-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from chmiiller/master
Adds support for additionalData using…
- Loading branch information
Showing
11 changed files
with
265 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file renamed
BIN
+883 KB
...illiamrijksen.onesignal-android-1.0.0.zip → ...illiamrijksen.onesignal-android-1.1.0.zip
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,61 @@ | ||
// This is a test harness for your module | ||
// You should do something interesting in this harness | ||
// to test out the module and to provide instructions | ||
// to users on how to use it by example. | ||
|
||
|
||
// open a single window | ||
var win = Ti.UI.createWindow({ | ||
backgroundColor:'white' | ||
backgroundColor: 'white' | ||
}); | ||
|
||
var onesignal = require('com.williamrijksen.onesignal'); | ||
|
||
var addTag = Ti.UI.createButton({ | ||
title: 'Add a tag', | ||
width: Ti.UI.FILL, | ||
height: Ti.UI.FILL, | ||
color: 'black', | ||
opacity: 0.8, | ||
backgroundColor: 'transparent', | ||
borderColor: '#4ee47f', | ||
top: 60 | ||
}); | ||
|
||
addTag.addEventListener('click', function(e) { | ||
onesignal.sendTag({ | ||
key: 'tag1', | ||
value: true | ||
}); | ||
alert('Tag added'); | ||
}); | ||
win.add(addTag); | ||
|
||
|
||
onesignal.addEventListener("notificationOpened", function(evt) { | ||
alert(evt); | ||
if (evt) { | ||
var title = ''; | ||
var content = ''; | ||
var data = {}; | ||
|
||
if (evt.title) { | ||
title = evt.title; | ||
} | ||
|
||
if (evt.body) { | ||
content = evt.body; | ||
} | ||
|
||
if (evt.additionalData) { | ||
if (Ti.Platform.osname === 'android') { | ||
//Android receives it as a JSON string | ||
data = JSON.parse(evt.additionalData); | ||
} else { | ||
data = evt.additionalData; | ||
} | ||
} | ||
|
||
alert("Notification opened! title: " + title + ', content: ' + content + ', data: ' + evt.additionalData); | ||
} | ||
}); | ||
|
||
onesignal.addEventListener("notificationReceived", function(evt) { | ||
alert(' ***** Received! ' + JSON.stringify(evt)); | ||
}); | ||
var label = Ti.UI.createLabel(); | ||
win.add(label); | ||
win.open(); | ||
|
||
// TODO: write your module tests here | ||
var com_williamrijksen_onesignal = require('com.williamrijksen.onesignal'); | ||
Ti.API.info("module is => " + com_williamrijksen_onesignal); | ||
|
||
label.text = com_williamrijksen_onesignal.example(); | ||
|
||
Ti.API.info("module exampleProp is => " + com_williamrijksen_onesignal.exampleProp); | ||
com_williamrijksen_onesignal.exampleProp = "This is a test value"; | ||
|
||
if (Ti.Platform.name == "android") { | ||
var proxy = com_williamrijksen_onesignal.createExample({ | ||
message: "Creating an example Proxy", | ||
backgroundColor: "red", | ||
width: 100, | ||
height: 100, | ||
top: 100, | ||
left: 150 | ||
}); | ||
|
||
proxy.printMessage("Hello world!"); | ||
proxy.message = "Hi world!. It's me again."; | ||
proxy.printMessage("Hello world!"); | ||
win.add(proxy); | ||
} | ||
|
||
win.open(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,61 @@ | ||
// This is a test harness for your module | ||
// You should do something interesting in this harness | ||
// to test out the module and to provide instructions | ||
// to users on how to use it by example. | ||
|
||
|
||
// open a single window | ||
var win = Ti.UI.createWindow({ | ||
backgroundColor:'white' | ||
backgroundColor: 'white' | ||
}); | ||
var label = Ti.UI.createLabel(); | ||
win.add(label); | ||
win.open(); | ||
|
||
// TODO: write your module tests here | ||
var com_williamrijksen_onesignal = require('com.williamrijksen.onesignal'); | ||
Ti.API.info("module is => " + com_williamrijksen_onesignal); | ||
|
||
label.text = com_williamrijksen_onesignal.example(); | ||
|
||
Ti.API.info("module exampleProp is => " + com_williamrijksen_onesignal.exampleProp); | ||
com_williamrijksen_onesignal.exampleProp = "This is a test value"; | ||
var onesignal = require('com.williamrijksen.onesignal'); | ||
|
||
var addTag = Ti.UI.createButton({ | ||
title: 'Add a tag', | ||
width: Ti.UI.FILL, | ||
height: Ti.UI.FILL, | ||
color: 'black', | ||
opacity: 0.8, | ||
backgroundColor: 'transparent', | ||
borderColor: '#4ee47f', | ||
top: 60 | ||
}); | ||
|
||
if (Ti.Platform.name == "android") { | ||
var proxy = com_williamrijksen_onesignal.createExample({ | ||
message: "Creating an example Proxy", | ||
backgroundColor: "red", | ||
width: 100, | ||
height: 100, | ||
top: 100, | ||
left: 150 | ||
}); | ||
addTag.addEventListener('click', function(e) { | ||
onesignal.sendTag({ | ||
key: 'tag1', | ||
value: true | ||
}); | ||
alert('Tag added'); | ||
}); | ||
win.add(addTag); | ||
|
||
|
||
onesignal.addEventListener("notificationOpened", function(evt) { | ||
alert(evt); | ||
if (evt) { | ||
var title = ''; | ||
var content = ''; | ||
var data = {}; | ||
|
||
if (evt.title) { | ||
title = evt.title; | ||
} | ||
|
||
if (evt.body) { | ||
content = evt.body; | ||
} | ||
|
||
if (evt.additionalData) { | ||
if (Ti.Platform.osname === 'android') { | ||
//Android receives it as a JSON string | ||
data = JSON.parse(evt.additionalData); | ||
} else { | ||
data = evt.additionalData; | ||
} | ||
} | ||
|
||
alert("Notification opened! title: " + title + ', content: ' + content + ', data: ' + evt.additionalData); | ||
} | ||
}); | ||
|
||
proxy.printMessage("Hello world!"); | ||
proxy.message = "Hi world!. It's me again."; | ||
proxy.printMessage("Hello world!"); | ||
win.add(proxy); | ||
} | ||
onesignal.addEventListener("notificationReceived", function(evt) { | ||
alert(' ***** Received! ' + JSON.stringify(evt)); | ||
}); | ||
|
||
win.open(); |
Oops, something went wrong.