Skip to content

Commit

Permalink
A little bit of error checking and typo in the readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
agramonte committed Sep 4, 2018
1 parent a44b9c2 commit 6284e86
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ notifyListerner, --- Listerner you want to recieve the events.
```
7. iOS example:
```json
Resposne: {
Response: {
"data":{
"name":"notification",
"type":"remote",
Expand All @@ -41,7 +41,7 @@ Resposne: {
```
8. Android example:
```json
Resposne: {
Response: {
"data":{
"name":"notification",
"type":"remote",
Expand Down
31 changes: 29 additions & 2 deletions notification.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,38 @@ N.notificationListener = function( event )
end
end

N.isError = function(appId)

N.registerDevice = function(appId, language, sessions)
local isError = false
local errorString = ""

if system.getInfo("environment") == "simulator" then
N.eventDispatcher:dispatchEvent( { name="notify", type="error", data="Not supported on simulator"} )
errorString = errorString.."Not supported on simulator. "
isError = true
end

if appId == nil then
errorString = errorString.."App Id cannot be nil. "
isError = true
return
end

if deviceToken == nil then
errorString = errorString.."Device token cannot be nil."
isError = true
return
end

if isError == true then
N.eventDispatcher:dispatchEvent( { name="notify", type="error", data=errorString} )
end

return isError
end

N.registerDevice = function(appId, language, sessions)

if N.isError(appId) == true then
return
end

Expand Down

0 comments on commit 6284e86

Please sign in to comment.