Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add subscribe method to subscribe to a GCM topic
Add stripped down google-play-services jar as a dependency for GcmPubSub Add example for subscribing to a topic Documentation updates Add Apache License to all Java files
- Loading branch information
Showing
11 changed files
with
319 additions
and
113 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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
var gcm = require("nl.vanvianen.android.gcm"); | ||
|
||
gcm.subscribe({ | ||
/* The Sender ID from Google Developers Console, see https://console.developers.google.com/project/XXXXXXXX/apiui/credential */ | ||
/* It's the same as your project id */ | ||
senderId: 'XXXXXXXX', | ||
/* Should start with "/topics/" */ | ||
topic: '/topics/mytopic', | ||
notificationSettings: { | ||
vibrate: true /* Whether the phone should vibrate, see the push notification example for more settings */ | ||
}, | ||
success: function (event) { | ||
Ti.API.info("Topic registration success: " + JSON.stringify(event)); | ||
}, | ||
error: function (event) { | ||
Ti.API.info("Topic registration error: " + JSON.stringify(event)); | ||
alert(event.error); | ||
}, | ||
callback: function (event) { | ||
Ti.API.info("Topic callback = " + JSON.stringify(event)); | ||
/* Called when a notification is received and the app is in the foreground */ | ||
|
||
var dialog = Ti.UI.createAlertDialog({ | ||
title: 'Topic received', | ||
message: JSON.stringify(event.data), | ||
buttonNames: ['View','Cancel'], | ||
cancel: 1 | ||
}); | ||
dialog.addEventListener("click", function(event) { | ||
dialog.hide(); | ||
if (event.index == 0) { | ||
/* Do stuff to view the notification */ | ||
} | ||
}); | ||
dialog.show(); | ||
} | ||
}); |
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
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
Oops, something went wrong.