Skip to content

Commit

Permalink
ti.playservices
Browse files Browse the repository at this point in the history
  • Loading branch information
m1ga committed Dec 17, 2017
1 parent 32763b5 commit 7aeaab9
Show file tree
Hide file tree
Showing 20 changed files with 64 additions and 67 deletions.
62 changes: 61 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,33 @@ TiGoosh.registerForPushNotifications({
```js
TiGoosh.unregisterForPushNotifications();
```

## Subscribe/unsubscribe to topics
```js
// 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")
}
})
```
## Are notifications enabled
It will return false if users have disabled notifications from the settings for the app, work from to API 19 (Android 4.4).
Not work for android before API 19 (Android 4.4), return true.
Expand Down Expand Up @@ -237,6 +264,40 @@ echo json_encode($json, JSON_PRETTY_PRINT);
echo exec("curl -X POST -H 'Authorization: key=" . GOOGLE_KEY . "' -H 'Content-Type: application/json' --data " . escapeshellarg(json_encode($json)) . ' https://android.googleapis.com/gcm/send');
```

Sending a message to a topic
```php
<?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;
```

## Handle the notification on the app

The payload of the notifications is the same that comes from your server.
Expand All @@ -258,4 +319,3 @@ A boolean value indicating if the notification has come when the app was in back
## LICENSE

MIT.

Binary file modified android/dist/ti.goosh-android-4.0.0.zip
Binary file not shown.
Binary file modified android/dist/ti.goosh.jar
Binary file not shown.
Binary file removed android/lib/play-services-base-11.0.4.jar
Binary file not shown.
Binary file removed android/lib/play-services-basement-11.0.4.jar
Binary file not shown.
Binary file removed android/lib/play-services-gcm-11.0.4.jar
Binary file not shown.
Binary file removed android/lib/play-services-iid-11.0.4.jar
Binary file not shown.
Binary file removed android/lib/play-services-tasks-11.0.4.jar
Binary file not shown.
Binary file modified android/libs/armeabi-v7a/libti.goosh.so
Binary file not shown.
Binary file modified android/libs/x86/libti.goosh.so
Binary file not shown.
2 changes: 0 additions & 2 deletions android/proguard/README

This file was deleted.

Binary file removed android/proguard/google-play-services.jar
Binary file not shown.
1 change: 0 additions & 1 deletion android/proguard/make.sh

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
63 changes: 0 additions & 63 deletions android/proguard/proguard.conf

This file was deleted.

3 changes: 3 additions & 0 deletions android/timodule.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,7 @@

</manifest>
</android>
<modules>
<module platform="android">ti.playservices</module>
</modules>
</ti:module>

0 comments on commit 7aeaab9

Please sign in to comment.