Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscribe to topics #82

Merged
merged 3 commits into from
Oct 10, 2017
Merged

Subscribe to topics #82

merged 3 commits into from
Oct 10, 2017

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Oct 9, 2017

Adding the possibility to subscribe to topics:

Subscribe:

TiGoosh.subscribe({
	topic: "/topics/myTopic",
	success: function(e) {
		console.log("unsub done " + e);
	},
	error: function(e){
		console.error("error")
	}
})

Unsubscribe:

TiGoosh.unsubscribe({
	topic: "/topics/myTopic",
	success: function(e) {
		console.log("unsub done " + e);
	},
	error: function(e){
		console.error("error")
	}
})

PHP test:

<?php
// API access key from Google API's Console
define('API_ACCESS_KEY', '.......');
// prep the bundle
$msg = array
(
'body' => 'This is a message sent from my http server',
'title' => 'From server side',
'priority' => 'high',
'sound' => 'default',
'time_to_live' => 3600
);
$fields = array('to' => '/topics/myTopic', 'notification' => $msg);

$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
curl_close($ch);
echo $result;

@m1ga
Copy link
Contributor Author

m1ga commented Oct 9, 2017

@Jei just saw your branch so I've forked from it to create my PR

@m1ga m1ga mentioned this pull request Oct 9, 2017
@Jei
Copy link
Contributor

Jei commented Oct 10, 2017

Thank you!
Did you try to compile the module though? I'm having problems with missing classes. I'll try again today and see if i can find the problem.

@m1ga
Copy link
Contributor Author

m1ga commented Oct 10, 2017

With your aar files it worked without a problem. Tested it with 6.2.2.GA

@Jei
Copy link
Contributor

Jei commented Oct 10, 2017

Ok, i forgot to select the correct SDK 🙃. I'm using 6.2.0.GA now.
I'm merging this and making a new major release, since this will not be compatible with older Titanium versions.

@Jei Jei merged commit 1a300c0 into caffeinalab:master Oct 10, 2017
@m1ga
Copy link
Contributor Author

m1ga commented Oct 10, 2017

ok, I didn't test it with an older version, but good that you found that issue 👍

@DouglasHennrich
Copy link

I have looked into platform/res/values/version.xml and it's using this8487000 version of google play service?
<integer name="google_play_services_version">8487000</integer>

Shouldn't it be 11020000 or higher ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants