diff --git a/README.md b/README.md index b328b64..c608e5e 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 + '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. @@ -258,4 +319,3 @@ A boolean value indicating if the notification has come when the app was in back ## LICENSE MIT. - diff --git a/android/dist/ti.goosh-android-4.0.0.zip b/android/dist/ti.goosh-android-4.0.0.zip new file mode 100644 index 0000000..950f97d Binary files /dev/null and b/android/dist/ti.goosh-android-4.0.0.zip differ diff --git a/android/dist/ti.goosh.jar b/android/dist/ti.goosh.jar index 06f1282..f93e126 100644 Binary files a/android/dist/ti.goosh.jar and b/android/dist/ti.goosh.jar differ diff --git a/android/lib/play-services-base-11.0.4.jar b/android/lib/play-services-base-11.0.4.jar deleted file mode 100644 index 9c549e4..0000000 Binary files a/android/lib/play-services-base-11.0.4.jar and /dev/null differ diff --git a/android/lib/play-services-basement-11.0.4.jar b/android/lib/play-services-basement-11.0.4.jar deleted file mode 100644 index 7bb1818..0000000 Binary files a/android/lib/play-services-basement-11.0.4.jar and /dev/null differ diff --git a/android/lib/play-services-gcm-11.0.4.jar b/android/lib/play-services-gcm-11.0.4.jar deleted file mode 100644 index b55f6da..0000000 Binary files a/android/lib/play-services-gcm-11.0.4.jar and /dev/null differ diff --git a/android/lib/play-services-iid-11.0.4.jar b/android/lib/play-services-iid-11.0.4.jar deleted file mode 100644 index 9fe91ee..0000000 Binary files a/android/lib/play-services-iid-11.0.4.jar and /dev/null differ diff --git a/android/lib/play-services-tasks-11.0.4.jar b/android/lib/play-services-tasks-11.0.4.jar deleted file mode 100644 index 9bb025f..0000000 Binary files a/android/lib/play-services-tasks-11.0.4.jar and /dev/null differ diff --git a/android/libs/armeabi-v7a/libti.goosh.so b/android/libs/armeabi-v7a/libti.goosh.so index c916a4c..45fd0d8 100644 Binary files a/android/libs/armeabi-v7a/libti.goosh.so and b/android/libs/armeabi-v7a/libti.goosh.so differ diff --git a/android/libs/x86/libti.goosh.so b/android/libs/x86/libti.goosh.so index 9094173..dc9e197 100644 Binary files a/android/libs/x86/libti.goosh.so and b/android/libs/x86/libti.goosh.so differ diff --git a/android/manifest b/android/manifest old mode 100755 new mode 100644 index 8dffe91..ebcd0fb --- a/android/manifest +++ b/android/manifest @@ -2,9 +2,9 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 3.0.3 -apiversion: 3 -architectures: armeabi-v7a x86 +version: 4.0.0 +apiversion: 4 +architectures: arm64-v8a armeabi-v7a x86 description: ti.goosh author: Flavio De Stefano license: MIT @@ -15,4 +15,4 @@ name: ti.goosh moduleid: ti.goosh guid: 5ad17cbc-1fed-4f20-8f27-6d1baa49ea9f platform: android -minsdk: 6.2.0 +minsdk: 7.0.0 diff --git a/android/proguard/README b/android/proguard/README deleted file mode 100644 index 0f71ce7..0000000 --- a/android/proguard/README +++ /dev/null @@ -1,2 +0,0 @@ -Use the make to build a stripped version of the Google Play Services -The actual "google-play-services.jar" file is at revision 29, downloaded from https://dl-ssl.google.com/android/repository/google_play_services_8487000_r29.zip diff --git a/android/proguard/google-play-services.jar b/android/proguard/google-play-services.jar deleted file mode 100644 index c4e0972..0000000 Binary files a/android/proguard/google-play-services.jar and /dev/null differ diff --git a/android/proguard/make.sh b/android/proguard/make.sh deleted file mode 100755 index 789cad3..0000000 --- a/android/proguard/make.sh +++ /dev/null @@ -1 +0,0 @@ -java -jar /usr/local/opt/proguard/libexec/proguard.jar @proguard.conf diff --git a/android/proguard/play-services-11.0.4/play-services-base-11.0.4.jar b/android/proguard/play-services-11.0.4/play-services-base-11.0.4.jar deleted file mode 100644 index 9c549e4..0000000 Binary files a/android/proguard/play-services-11.0.4/play-services-base-11.0.4.jar and /dev/null differ diff --git a/android/proguard/play-services-11.0.4/play-services-basement-11.0.4.jar b/android/proguard/play-services-11.0.4/play-services-basement-11.0.4.jar deleted file mode 100644 index 7bb1818..0000000 Binary files a/android/proguard/play-services-11.0.4/play-services-basement-11.0.4.jar and /dev/null differ diff --git a/android/proguard/play-services-11.0.4/play-services-gcm-11.0.4.jar b/android/proguard/play-services-11.0.4/play-services-gcm-11.0.4.jar deleted file mode 100644 index b55f6da..0000000 Binary files a/android/proguard/play-services-11.0.4/play-services-gcm-11.0.4.jar and /dev/null differ diff --git a/android/proguard/play-services-11.0.4/play-services-iid-11.0.4.jar b/android/proguard/play-services-11.0.4/play-services-iid-11.0.4.jar deleted file mode 100644 index 9fe91ee..0000000 Binary files a/android/proguard/play-services-11.0.4/play-services-iid-11.0.4.jar and /dev/null differ diff --git a/android/proguard/play-services-11.0.4/play-services-tasks-11.0.4.jar b/android/proguard/play-services-11.0.4/play-services-tasks-11.0.4.jar deleted file mode 100644 index 9bb025f..0000000 Binary files a/android/proguard/play-services-11.0.4/play-services-tasks-11.0.4.jar and /dev/null differ diff --git a/android/proguard/proguard.conf b/android/proguard/proguard.conf deleted file mode 100644 index 82514cc..0000000 --- a/android/proguard/proguard.conf +++ /dev/null @@ -1,63 +0,0 @@ --injars play-services-11.0.4 --outjars ../lib/google-play-services-tigoosh.jar - --libraryjars /opt/android/extras/android/support/v4/android-support-v4.jar --libraryjars /opt/android/extras/android/support/v7/mediarouter/libs/android-support-v7-mediarouter.jar --libraryjars /opt/android/platforms/android-23/android.jar --libraryjars /opt/android/platforms/android-22/android.jar - --dontoptimize --dontobfuscate --dontwarn com.google.**.R --dontwarn com.google.**.R$* --dontnote - --keep class * extends java.util.ListResourceBundle { - protected java.lang.Object[][] getContents(); -} - -# Keep SafeParcelable value, needed for reflection. This is required to support backwards -# compatibility of some classes. --keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable { - public static final *** NULL; -} - -# Keep the names of classes/members we need for client functionality. --keep @interface com.google.android.gms.common.annotation.KeepName --keepnames @com.google.android.gms.common.annotation.KeepName class * --keepclassmembernames class * { - @com.google.android.gms.common.annotation.KeepName *; -} - -# Needed for Parcelable/SafeParcelable Creators to not get stripped --keepnames class * implements android.os.Parcelable { - public static final ** CREATOR; -} - -# Needed when building against pre-Marshmallow SDK. --dontwarn android.security.NetworkSecurityPolicy - -# Keep metadata about included modules. --keep public class com.google.android.gms.dynamite.descriptors.** { - public ; -} - -# Keep the implementation of the flags api for google-play-services-flags - --keep public class com.google.android.gms.flags.impl.FlagProviderImpl { - public ; public ; -} - - -# Add GCM --keep public class com.google.android.gms.gcm.** { - public protected *; -} - --keep public class com.google.android.gms.iid.** { - public protected *; -} - --keep public class com.google.android.gms.common.** { - public protected *; -} diff --git a/android/timodule.xml b/android/timodule.xml index f707079..bd6f062 100755 --- a/android/timodule.xml +++ b/android/timodule.xml @@ -71,4 +71,7 @@ + + ti.playservices +