rho-tau-extensions 6.2.0 → 7.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/libs/crosswalk/ext/platform/android/Rakefile +19 -1
  3. data/libs/enterprise-barcode/ext/platform/android/adds/lib/aarch64/liballbarcode.a +0 -0
  4. data/libs/enterprise-barcode/ext/platform/android/adds/lib/armeabi/liballbarcode.a +0 -0
  5. data/libs/enterprise-barcode/ext/platform/android/adds/lib/x86/liballbarcode.a +0 -0
  6. data/libs/enterprise-barcode/ext/platform/android/allbarcode.jar +0 -0
  7. data/libs/fcm-push-18/ext.yml +20 -0
  8. data/libs/fcm-push-18/ext/android/AndroidManifest.rb +10 -0
  9. data/libs/fcm-push-18/ext/android/ApplicationManifestAdds.erb +39 -0
  10. data/libs/fcm-push-18/ext/android/Rakefile +187 -0
  11. data/libs/fcm-push-18/ext/android/ext_java.files +3 -0
  12. data/libs/fcm-push-18/ext/android/ext_native.files +1 -0
  13. data/libs/fcm-push-18/ext/android/jni/src/fcmpushclient.cpp +215 -0
  14. data/libs/fcm-push-18/ext/android/jni/src/fcmpushclient.h +74 -0
  15. data/libs/fcm-push-18/ext/android/res/res/values/fireBaseValues.xml +5 -0
  16. data/libs/fcm-push-18/ext/android/src/com/rhomobile/rhodes/fcm/FCMFacade.java +164 -0
  17. data/libs/fcm-push-18/ext/android/src/com/rhomobile/rhodes/fcm/FCMIntentService.java +219 -0
  18. data/libs/fcm-push-18/ext/android/src/com/rhomobile/rhodes/fcm/FCMListener.java +88 -0
  19. data/libs/fcm-push-18/ext/build +16 -0
  20. data/libs/fcm-push-18/ext/build.bat +8 -0
  21. data/libs/fcm-push-18/ext/fcm.xml +9 -0
  22. data/libs/fcm-push-18/ext/iphone/ApplePush_Prefix.pch +7 -0
  23. data/libs/fcm-push-18/ext/iphone/Firebase.h +68 -0
  24. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/FirebaseAnalytics +0 -0
  25. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalytics+AppDelegate.h +62 -0
  26. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalytics.h +115 -0
  27. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalyticsConfiguration.h +1 -0
  28. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRAnalyticsSwiftNameSupport.h +13 -0
  29. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRApp.h +1 -0
  30. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRConfiguration.h +1 -0
  31. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIREventNames.h +389 -0
  32. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIROptions.h +1 -0
  33. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRParameterNames.h +485 -0
  34. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FIRUserPropertyNames.h +15 -0
  35. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Headers/FirebaseAnalytics.h +10 -0
  36. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseAnalytics.framework/Modules/module.modulemap +10 -0
  37. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/FirebaseCore +0 -0
  38. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Headers/FIRAnalyticsConfiguration.h +52 -0
  39. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Headers/FIRApp.h +130 -0
  40. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Headers/FIRConfiguration.h +78 -0
  41. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Headers/FIRLoggerLevel.h +35 -0
  42. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Headers/FIROptions.h +133 -0
  43. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Headers/FirebaseCore.h +5 -0
  44. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCore.framework/Modules/module.modulemap +7 -0
  45. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCoreDiagnostics.framework/FirebaseCoreDiagnostics +0 -0
  46. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseCoreDiagnostics.framework/Modules/module.modulemap +6 -0
  47. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseInstanceID.framework/FirebaseInstanceID +0 -0
  48. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseInstanceID.framework/Headers/FIRInstanceID.h +276 -0
  49. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseInstanceID.framework/Headers/FirebaseInstanceID.h +1 -0
  50. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseInstanceID.framework/Modules/module.modulemap +7 -0
  51. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseMessaging.framework/FirebaseMessaging +0 -0
  52. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseMessaging.framework/Headers/FIRMessaging.h +508 -0
  53. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseMessaging.framework/Headers/FirebaseMessaging.h +1 -0
  54. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseMessaging.framework/Modules/module.modulemap +8 -0
  55. data/libs/fcm-push-18/ext/iphone/Frameworks/FirebaseNanoPB.framework/FirebaseNanoPB +0 -0
  56. data/libs/fcm-push-18/ext/iphone/Frameworks/GoogleToolboxForMac.framework/GoogleToolboxForMac +0 -0
  57. data/libs/fcm-push-18/ext/iphone/Frameworks/GoogleToolboxForMac.framework/Modules/module.modulemap +5 -0
  58. data/libs/fcm-push-18/ext/iphone/Frameworks/Protobuf.framework/Modules/module.modulemap +5 -0
  59. data/libs/fcm-push-18/ext/iphone/Frameworks/Protobuf.framework/Protobuf +0 -0
  60. data/libs/fcm-push-18/ext/iphone/Frameworks/nanopb.framework/Modules/module.modulemap +5 -0
  61. data/libs/fcm-push-18/ext/iphone/Frameworks/nanopb.framework/nanopb +0 -0
  62. data/libs/fcm-push-18/ext/iphone/Rakefile +81 -0
  63. data/libs/fcm-push-18/ext/iphone/fcm-push.xcodeproj/project.pbxproj +370 -0
  64. data/libs/fcm-push-18/ext/iphone/impl/PushNotificationsReceiver.h +28 -0
  65. data/libs/fcm-push-18/ext/iphone/impl/PushNotificationsReceiver.m +27 -0
  66. data/libs/fcm-push-18/ext/iphone/impl/PushNotificationsReceiver.mm +234 -0
  67. data/libs/fcm-push-18/ext/iphone/impl/applePushSetup.c +10 -0
  68. data/libs/fcm-push-18/ext/iphone/impl/applepushclient.h +69 -0
  69. data/libs/fcm-push-18/ext/iphone/impl/applepushclient.mm +164 -0
  70. data/libs/fcm-push-18/ext/iphone/impl/readme.txt +7 -0
  71. data/libs/fcm-push-18/ext/platform/iphone/impl/readme.txt +7 -0
  72. data/libs/nodejs/ext/platform/android/jxCore/jx.h +17 -1
  73. data/libs/nodejs/ext/platform/android/jxCore/libcares_arm.a +0 -0
  74. data/libs/nodejs/ext/platform/android/jxCore/libcares_ia32.a +0 -0
  75. data/libs/nodejs/ext/platform/android/jxCore/libcares_x64.a +0 -0
  76. data/libs/nodejs/ext/platform/android/jxCore/libchrome_zlib_arm.a +0 -0
  77. data/libs/nodejs/ext/platform/android/jxCore/libchrome_zlib_ia32.a +0 -0
  78. data/libs/nodejs/ext/platform/android/jxCore/libchrome_zlib_x64.a +0 -0
  79. data/libs/nodejs/ext/platform/android/jxCore/libhttp_parser_arm.a +0 -0
  80. data/libs/nodejs/ext/platform/android/jxCore/libhttp_parser_ia32.a +0 -0
  81. data/libs/nodejs/ext/platform/android/jxCore/libhttp_parser_x64.a +0 -0
  82. data/libs/nodejs/ext/platform/android/jxCore/libjx_arm.a +0 -0
  83. data/libs/nodejs/ext/platform/android/jxCore/libjx_ia32.a +0 -0
  84. data/libs/nodejs/ext/platform/android/jxCore/libjx_x64.a +0 -0
  85. data/libs/nodejs/ext/platform/android/jxCore/libopenssl_arm.a +0 -0
  86. data/libs/nodejs/ext/platform/android/jxCore/libopenssl_ia32.a +0 -0
  87. data/libs/nodejs/ext/platform/android/jxCore/libopenssl_x64.a +0 -0
  88. data/libs/nodejs/ext/platform/android/jxCore/libsqlite3_arm.a +0 -0
  89. data/libs/nodejs/ext/platform/android/jxCore/libsqlite3_ia32.a +0 -0
  90. data/libs/nodejs/ext/platform/android/jxCore/libsqlite3_x64.a +0 -0
  91. data/libs/nodejs/ext/platform/android/jxCore/libuv_arm.a +0 -0
  92. data/libs/nodejs/ext/platform/android/jxCore/libuv_ia32.a +0 -0
  93. data/libs/nodejs/ext/platform/android/jxCore/libuv_x64.a +0 -0
  94. data/libs/nodejs/ext/platform/android/jxCore/libv8_base_arm.a +0 -0
  95. data/libs/nodejs/ext/platform/android/jxCore/libv8_base_ia32.a +0 -0
  96. data/libs/nodejs/ext/platform/android/jxCore/libv8_base_x64.a +0 -0
  97. data/libs/nodejs/ext/platform/android/jxCore/libv8_nosnapshot_arm.a +0 -0
  98. data/libs/nodejs/ext/platform/android/jxCore/libv8_nosnapshot_ia32.a +0 -0
  99. data/libs/nodejs/ext/platform/android/jxCore/libv8_nosnapshot_x64.a +0 -0
  100. data/libs/nodejs/ext/platform/iphone/jxCore/jx.h +17 -1
  101. data/libs/nodejs/ext/platform/iphone/jxCore/libcares.a +0 -0
  102. data/libs/nodejs/ext/platform/iphone/jxCore/libchrome_zlib.a +0 -0
  103. data/libs/nodejs/ext/platform/iphone/jxCore/libhttp_parser.a +0 -0
  104. data/libs/nodejs/ext/platform/iphone/jxCore/libjx.a +0 -0
  105. data/libs/nodejs/ext/platform/iphone/jxCore/libmozjs.a +0 -0
  106. data/libs/nodejs/ext/platform/iphone/jxCore/libopenssl.a +0 -0
  107. data/libs/nodejs/ext/platform/iphone/jxCore/libsqlite3.a +0 -0
  108. data/libs/nodejs/ext/platform/iphone/jxCore/libuv.a +0 -0
  109. data/libs/rexml-edge/rexml/attlistdecl.rb +63 -0
  110. data/libs/rexml-edge/rexml/attribute.rb +192 -0
  111. data/libs/rexml-edge/rexml/cdata.rb +68 -0
  112. data/libs/rexml-edge/rexml/child.rb +97 -0
  113. data/libs/rexml-edge/rexml/comment.rb +80 -0
  114. data/libs/rexml-edge/rexml/doctype.rb +270 -0
  115. data/libs/rexml-edge/rexml/document.rb +291 -0
  116. data/libs/rexml-edge/rexml/dtd/attlistdecl.rb +11 -0
  117. data/libs/rexml-edge/rexml/dtd/dtd.rb +47 -0
  118. data/libs/rexml-edge/rexml/dtd/elementdecl.rb +18 -0
  119. data/libs/rexml-edge/rexml/dtd/entitydecl.rb +57 -0
  120. data/libs/rexml-edge/rexml/dtd/notationdecl.rb +40 -0
  121. data/libs/rexml-edge/rexml/element.rb +1241 -0
  122. data/libs/rexml-edge/rexml/encoding.rb +51 -0
  123. data/libs/rexml-edge/rexml/entity.rb +174 -0
  124. data/libs/rexml-edge/rexml/formatters/default.rb +112 -0
  125. data/libs/rexml-edge/rexml/formatters/pretty.rb +142 -0
  126. data/libs/rexml-edge/rexml/formatters/transitive.rb +58 -0
  127. data/libs/rexml-edge/rexml/functions.rb +418 -0
  128. data/libs/rexml-edge/rexml/instruction.rb +71 -0
  129. data/libs/rexml-edge/rexml/light/node.rb +196 -0
  130. data/libs/rexml-edge/rexml/namespace.rb +48 -0
  131. data/libs/rexml-edge/rexml/node.rb +76 -0
  132. data/libs/rexml-edge/rexml/output.rb +30 -0
  133. data/libs/rexml-edge/rexml/parent.rb +166 -0
  134. data/libs/rexml-edge/rexml/parseexception.rb +52 -0
  135. data/libs/rexml-edge/rexml/parsers/baseparser.rb +533 -0
  136. data/libs/rexml-edge/rexml/parsers/lightparser.rb +59 -0
  137. data/libs/rexml-edge/rexml/parsers/pullparser.rb +197 -0
  138. data/libs/rexml-edge/rexml/parsers/sax2parser.rb +273 -0
  139. data/libs/rexml-edge/rexml/parsers/streamparser.rb +61 -0
  140. data/libs/rexml-edge/rexml/parsers/treeparser.rb +101 -0
  141. data/libs/rexml-edge/rexml/parsers/ultralightparser.rb +57 -0
  142. data/libs/rexml-edge/rexml/parsers/xpathparser.rb +657 -0
  143. data/libs/rexml-edge/rexml/quickpath.rb +266 -0
  144. data/libs/rexml-edge/rexml/rexml.rb +32 -0
  145. data/libs/rexml-edge/rexml/sax2listener.rb +98 -0
  146. data/libs/rexml-edge/rexml/security.rb +28 -0
  147. data/libs/rexml-edge/rexml/source.rb +297 -0
  148. data/libs/rexml-edge/rexml/streamlistener.rb +93 -0
  149. data/libs/rexml-edge/rexml/syncenumerator.rb +33 -0
  150. data/libs/rexml-edge/rexml/text.rb +426 -0
  151. data/libs/rexml-edge/rexml/undefinednamespaceexception.rb +9 -0
  152. data/libs/rexml-edge/rexml/validation/relaxng.rb +539 -0
  153. data/libs/rexml-edge/rexml/validation/validation.rb +144 -0
  154. data/libs/rexml-edge/rexml/validation/validationexception.rb +10 -0
  155. data/libs/rexml-edge/rexml/xmldecl.rb +116 -0
  156. data/libs/rexml-edge/rexml/xmltokens.rb +85 -0
  157. data/libs/rexml-edge/rexml/xpath.rb +81 -0
  158. data/libs/rexml-edge/rexml/xpath_parser.rb +704 -0
  159. data/version +1 -1
  160. metadata +118 -2
@@ -0,0 +1,74 @@
1
+ /*------------------------------------------------------------------------
2
+ * (The MIT License)
3
+ *
4
+ * Copyright (c) 2008-2012 Rhomobile, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ *
24
+ * http://rhomobile.com
25
+ *------------------------------------------------------------------------*/
26
+
27
+ #ifndef FCMPUSHCLIENT_H_
28
+ #define FCMPUSHCLIENT_H_
29
+
30
+ //#include "common/push/IRhoPushClient.h"
31
+ #include "Push.h"
32
+
33
+ #include "logging/RhoLog.h"
34
+ #include "common/RhoStd.h"
35
+ #include <queue>
36
+
37
+ namespace rho { namespace fcm {
38
+
39
+ using namespace rho::common;
40
+
41
+ class FcmPushClient: public push::CPushClient
42
+ {
43
+ class SyncLoginListener;
44
+ private:
45
+ static const char* const s_FCM_FACADE_CLASS;
46
+ static const String s_Type;
47
+ static String token;
48
+ CMethodResult m_oResult;
49
+ CMethodResult m_deviceIdResult;
50
+ void setPropertyFromMethod(const char* methodName, CMethodResult &result);
51
+ void refreshToken();
52
+
53
+ std::queue<String> callBacksQueue;
54
+ void executeCallBacks();
55
+ bool canExecuteNotifications;
56
+ public:
57
+ DEFINE_LOGCLASS;
58
+
59
+ FcmPushClient();
60
+ virtual ~FcmPushClient() {}
61
+
62
+ virtual const String& getId() const { return s_Type; }
63
+ virtual void setDeviceId(const String& deviceId);
64
+ virtual void getDeviceId(CMethodResult& result);
65
+ virtual void startNotifications(CMethodResult& result);
66
+ virtual void stopNotifications(CMethodResult& result);
67
+ virtual bool callBack(const String& json);
68
+
69
+ };
70
+
71
+
72
+ }}
73
+
74
+ #endif /* FCMPUSHCLIENT_H_ */
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <resources>
3
+ <string name="gcm_defaultSenderId" translatable="false">946233903142</string>
4
+ <string name="google_app_id" translatable="false">1:946233903142:android:f30764748b001126</string>
5
+ </resources>
@@ -0,0 +1,164 @@
1
+ /*------------------------------------------------------------------------
2
+ * (The MIT License)
3
+ *
4
+ * Copyright (c) 2008-2012 Rhomobile, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ *
24
+ * http://rhomobile.com
25
+ *------------------------------------------------------------------------*/
26
+
27
+ package com.rhomobile.rhodes.fcm;
28
+
29
+ import com.rhomobile.rhodes.Push;
30
+ import com.rhomobile.rhodes.Logger;
31
+ import com.rhomobile.rhodes.PushContract;
32
+ import com.rhomobile.rhodes.util.ContextFactory;
33
+ import com.rhomobile.rhodes.fcm.FCMIntentService;
34
+ import android.content.Intent;
35
+ import com.google.firebase.messaging.FirebaseMessagingService;
36
+ import com.google.firebase.messaging.RemoteMessage;
37
+ import com.google.firebase.FirebaseApp;
38
+ import com.google.firebase.FirebaseOptions;
39
+ import com.google.firebase.messaging.FirebaseMessaging;
40
+ import com.google.firebase.iid.FirebaseInstanceId;
41
+ import com.rhomobile.rhodes.R;
42
+ import java.lang.Throwable;
43
+ import com.rhomobile.rhodes.extmanager.AbstractRhoListener;
44
+ import com.rhomobile.rhodes.RhodesActivity;
45
+ import com.rhomobile.rhodes.RhodesService;
46
+ import com.rhomobile.rhodes.extmanager.RhoExtManager;
47
+ import com.rhomobile.rhodes.extmanager.RhoExtManagerImpl;
48
+ import com.rhomobile.rhodes.extmanager.IRhoExtManager;
49
+ import com.google.firebase.iid.InstanceIdResult;
50
+ import com.google.android.gms.tasks.OnCompleteListener;
51
+ import com.google.android.gms.tasks.Task;
52
+
53
+ public final class FCMFacade {
54
+ private static final String TAG = FCMFacade.class.getSimpleName();
55
+ public static final FCMListener listener = FCMListener.getInstance();
56
+
57
+ static final String FCM_PUSH_CLIENT = "fcm";
58
+ static String clientToken = "";
59
+
60
+ private static String gStr(int key){
61
+ String value = "";
62
+ try{
63
+ value = ContextFactory.getContext().getResources().getString(key);
64
+ }catch(Exception e){
65
+ Logger.W(TAG, "FCM: key " + key + " does not exist");
66
+ }
67
+ return value;
68
+ }
69
+
70
+ public static String google_app_id(){
71
+ return gStr(R.string.google_app_id);
72
+ }
73
+
74
+ public static String gcm_defaultSenderId() {
75
+ return gStr(R.string.gcm_defaultSenderId);
76
+ }
77
+
78
+ /*
79
+ public static String google_api_key(){
80
+ return gStr(R.string.google_api_key);
81
+ }
82
+ */
83
+
84
+ public static void initFireBase() {
85
+
86
+ Logger.W(TAG, "FCM: Send FCM push register req");
87
+
88
+ try{
89
+ FirebaseApp.getInstance();
90
+ Logger.T(TAG, "FCM: Firebase inited");
91
+ }catch(Exception exc){
92
+ FirebaseOptions options = null;
93
+ try {
94
+ options = new FirebaseOptions.Builder()
95
+ .setApplicationId(gStr(R.string.google_app_id))
96
+ //.setApiKey(gStr(R.string.google_api_key))
97
+ //.setDatabaseUrl(gStr(R.string.firebase_database_url))
98
+ //.setStorageBucket(gStr(R.string.google_storage_bucket))
99
+ .setGcmSenderId(gStr(R.string.gcm_defaultSenderId))
100
+ .build();
101
+ } catch( Throwable e ) {
102
+ Logger.E(TAG, "FCM: poblems on building options: " + e);
103
+ e.printStackTrace();
104
+ }
105
+ try{
106
+ FirebaseApp.initializeApp(ContextFactory.getContext(), options);
107
+ Logger.T(TAG, "FCM: initialization of application");
108
+ }catch(Exception e){
109
+ Logger.E(TAG, "FCM: poblems on initialization app: " + e);
110
+ e.printStackTrace();
111
+ }
112
+ try{
113
+ if (FirebaseApp.getInstance()==null){
114
+ Logger.T(TAG, "FCM: firebase app is null");
115
+ }
116
+ Logger.T(TAG, "FCM: Firebase Inited");
117
+ }catch(Exception e){
118
+ Logger.E(TAG, "FCM: poblems on getting instance: " + e);
119
+ e.printStackTrace();
120
+ }
121
+ }
122
+
123
+ refreshToken();
124
+
125
+ }
126
+ public static void refreshToken(){
127
+ try{
128
+ Logger.T(TAG, "FCM: registation of application");
129
+ clientToken = "";
130
+
131
+ new Thread(new Runnable() {
132
+ public void run() {
133
+ while (FirebaseInstanceId.getInstance(FirebaseApp.getInstance()) == null){
134
+ try{
135
+ Thread.sleep(1000);
136
+ }catch(Exception e){
137
+
138
+ }
139
+ Logger.T(TAG, "FCM: FirebaseInstanceId is null");
140
+ }
141
+ FirebaseInstanceId.getInstance(FirebaseApp.getInstance()).getInstanceId().addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
142
+ @Override
143
+ public void onComplete(Task<InstanceIdResult> task) {
144
+ if (task == null || !task.isSuccessful()) {
145
+ Logger.T(TAG, "FCM: can't get token, try to refresh later: " + task.getException());
146
+ return;
147
+ }
148
+ clientToken = task.getResult().getToken();
149
+ PushContract.handleRegistration(ContextFactory.getContext(), clientToken, FCMFacade.FCM_PUSH_CLIENT);
150
+ Logger.T(TAG, "FCM: registation successfully, token = " + clientToken);
151
+ }
152
+ });
153
+ }
154
+ }).start();
155
+
156
+
157
+
158
+ }catch(Exception exc){
159
+ Logger.T(TAG, "FCM: can't handle registation: " + exc);
160
+ }
161
+
162
+ }
163
+
164
+ }
@@ -0,0 +1,219 @@
1
+ /*------------------------------------------------------------------------
2
+ * (The MIT License)
3
+ *
4
+ * Copyright (c) 2008-2012 Rhomobile, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ *
24
+ * http://rhomobile.com
25
+ *------------------------------------------------------------------------*/
26
+
27
+ package com.rhomobile.rhodes.fcm;
28
+
29
+ import android.content.Context;
30
+ import android.content.Intent;
31
+ import android.graphics.BitmapFactory;
32
+ import android.media.RingtoneManager;
33
+ import android.net.Uri;
34
+
35
+ import android.app.Notification;
36
+ import android.app.NotificationChannel;
37
+ import android.app.NotificationManager;
38
+ import android.support.v4.app.NotificationCompat;
39
+
40
+ import android.app.PendingIntent;
41
+ import android.net.Uri;
42
+ import android.util.Log;
43
+ import android.os.Build;
44
+
45
+ import com.google.firebase.messaging.FirebaseMessagingService;
46
+ import com.google.firebase.messaging.RemoteMessage;
47
+ import com.rhomobile.rhodes.util.ContextFactory;
48
+ import com.rhomobile.rhodes.Logger;
49
+ import com.rhomobile.rhodes.PushContract;
50
+ import com.rhomobile.rhodes.R;
51
+ import com.rhomobile.rhodes.RhodesActivity;
52
+ import com.rhomobile.rhodes.R;
53
+
54
+
55
+ import com.google.firebase.FirebaseApp;
56
+ import com.google.firebase.FirebaseOptions;
57
+ import android.util.Log;
58
+ import java.util.HashMap;
59
+ import java.util.Map;
60
+ import java.util.Set;
61
+ import java.util.HashSet;
62
+ import org.json.JSONException;
63
+ import org.json.JSONObject;
64
+ import java.util.Timer;
65
+ import java.util.TimerTask;
66
+ import java.util.concurrent.TimeUnit;
67
+ import android.os.Handler;
68
+ import com.rhomobile.rhodes.fcm.FCMFacade;
69
+ import com.google.firebase.iid.FirebaseInstanceId;
70
+
71
+
72
+ public class FCMIntentService extends FirebaseMessagingService {
73
+
74
+ private static final String TAG = FCMIntentService.class.getSimpleName();
75
+ public static final FCMListener listener = FCMListener.getInstance();
76
+
77
+ private static final String CHANNEL_ID = "default";
78
+ private static Map<String, JSONObject> savedMessages = new HashMap<String, JSONObject>();
79
+
80
+ @Override
81
+ public void onNewToken(String token) {
82
+ Logger.I(TAG, "FCM: on new token: " + token);
83
+ super.onNewToken(token);
84
+ FCMFacade.refreshToken();
85
+ }
86
+
87
+ @Override
88
+ public void onCreate() {
89
+ super.onCreate();
90
+ if (Build.VERSION.SDK_INT >= 26) {
91
+ NotificationChannel channel = new NotificationChannel(CHANNEL_ID, getPackageName(), NotificationManager.IMPORTANCE_DEFAULT);
92
+ NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
93
+ notificationManager.createNotificationChannel(channel);
94
+ }
95
+ }
96
+
97
+
98
+ @Override
99
+ public void onMessageReceived(RemoteMessage remoteMessage) {
100
+ //savedIntents.remove(remoteMessage.getMessageId());
101
+
102
+ Logger.I(TAG, "FCM: onMessageReceived()");
103
+ Map<String, String> params = new HashMap<String, String>();
104
+
105
+ if (remoteMessage.getMessageId() != null) params.put("id", remoteMessage.getMessageId());
106
+ Logger.I(TAG, "FCM: id - " + remoteMessage.getMessageId());
107
+
108
+ if (remoteMessage.getFrom() != null) params.put("from", remoteMessage.getFrom());
109
+ Logger.I(TAG, "FCM: from - " + remoteMessage.getFrom());
110
+
111
+ if (remoteMessage.getTo() != null) params.put("to", remoteMessage.getTo());
112
+ Logger.I(TAG, "FCM: to - " + remoteMessage.getTo());
113
+
114
+ if (remoteMessage.getNotification() != null){
115
+ if (remoteMessage.getNotification().getBody() != null) params.put("body", remoteMessage.getNotification().getBody());
116
+ Logger.I(TAG, "FCM: body - " + remoteMessage.getNotification().getBody());
117
+
118
+ if (remoteMessage.getNotification().getTitle() != null) params.put("title", remoteMessage.getNotification().getTitle());
119
+ Logger.I(TAG, "FCM: title - " + remoteMessage.getNotification().getTitle());
120
+
121
+ if (remoteMessage.getNotification().getTag() != null) params.put("tag", remoteMessage.getNotification().getTag());
122
+ Logger.I(TAG, "FCM: tag - " + remoteMessage.getNotification().getTag());
123
+ }
124
+
125
+ String title = null;
126
+ String text = null;
127
+
128
+ try{
129
+ JSONObject jsonObject = new JSONObject(params);
130
+
131
+ try {
132
+ jsonObject.put("data", new JSONObject(remoteMessage.getData()));
133
+ Logger.I(TAG, "FCM: data - " + remoteMessage.getData());
134
+ title = remoteMessage.getData().get("notification_title");
135
+ text = remoteMessage.getData().get("notification_text");
136
+ } catch (JSONException e) {
137
+ Logger.I(TAG, "FCM: jsonObject generation error");
138
+ e.printStackTrace();
139
+ }
140
+
141
+ Logger.W(TAG, "FCM: push message in JSON: " + jsonObject.toString());
142
+ try{
143
+ PushContract.handleMessage(ContextFactory.getContext(), jsonObject.toString(), FCMFacade.FCM_PUSH_CLIENT);
144
+ }catch(Exception e){
145
+ if (params.containsKey("id")){
146
+ savedMessages.put(params.get("id"), jsonObject);
147
+ }
148
+ }
149
+ }catch(Exception e){
150
+ Logger.E(TAG, "FCM: can't create object for handleMessage");
151
+ e.printStackTrace();
152
+ }
153
+
154
+ if (title != null && text != null && !listener.applicationVisible()){
155
+ Intent resultIntent = new Intent(this, RhodesActivity.class);
156
+ PendingIntent resultPendingIntent = PendingIntent.getActivity(this, 0, resultIntent,
157
+ PendingIntent.FLAG_UPDATE_CURRENT);
158
+
159
+
160
+ NotificationCompat.Builder notificationBuilder = null;
161
+ if (Build.VERSION.SDK_INT >= 26) {
162
+ notificationBuilder = new NotificationCompat.Builder(this, "default");
163
+ }else{
164
+ notificationBuilder = new NotificationCompat.Builder(this);
165
+
166
+ }
167
+ notificationBuilder.setSmallIcon(R.mipmap.icon)
168
+ .setContentTitle(title)
169
+ .setContentText(text)
170
+ .setAutoCancel(true)
171
+ .setContentIntent(resultPendingIntent);
172
+
173
+ Notification notification = notificationBuilder.build();
174
+
175
+ NotificationManager notificationManager =
176
+ (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
177
+
178
+ notificationManager.notify(1, notification);
179
+ }
180
+
181
+
182
+ }
183
+
184
+ public static boolean tryToHandleMessage(JSONObject jsonObject){
185
+ try{
186
+ Logger.W(TAG, "FCM: tryToHandleMessage() - trying to handle saved JSONObject");
187
+ PushContract.handleMessage(ContextFactory.getContext(), jsonObject.toString(), FCMFacade.FCM_PUSH_CLIENT);
188
+ return true;
189
+ }catch(Exception e){
190
+ Logger.W(TAG, "FCM: tryToHandleMessage() - can't handle JSONObject");
191
+ }
192
+ return false;
193
+ }
194
+
195
+
196
+ static public void resume()
197
+ {
198
+ if (savedMessages.size() > 0){
199
+
200
+ Timer timerObj = new Timer();
201
+ TimerTask timerTaskObj = new TimerTask() {
202
+ public void run() {
203
+ Set<String> keySet = new HashSet<String>(savedMessages.keySet());
204
+ for (String key : keySet){
205
+ try{
206
+ if (tryToHandleMessage(savedMessages.get(key))){
207
+ savedMessages.remove(key);
208
+ }
209
+ }catch(Exception e){
210
+ Logger.W(TAG, "FCM: can't handle saved message " + key);
211
+ }
212
+ }
213
+ }
214
+ };
215
+ timerObj.schedule(timerTaskObj, 2000);
216
+ }
217
+ }
218
+
219
+ }