Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
react-native-notifications
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
冷佳娟
react-native-notifications
Commits
e434c620
Commit
e434c620
authored
Aug 12, 2019
by
Yogev Ben David
Committed by
GitHub
Aug 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove GCM leftovers (#359)
* Remove GCM leftovers, fix typos * Print android unit tests output
parent
b4030449
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
48 additions
and
62 deletions
+48
-62
android/app/build.gradle
android/app/build.gradle
+19
-0
android/app/src/main/AndroidManifest.xml
android/app/src/main/AndroidManifest.xml
+3
-3
android/app/src/main/java/com/wix/reactnativenotifications/Defs.java
.../src/main/java/com/wix/reactnativenotifications/Defs.java
+0
-1
android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java
...m/wix/reactnativenotifications/RNNotificationsModule.java
+4
-7
android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmInstanceIdListenerService.java
...nativenotifications/fcm/FcmInstanceIdListenerService.java
+5
-7
android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmInstanceIdRefreshHandlerService.java
...notifications/fcm/FcmInstanceIdRefreshHandlerService.java
+6
-6
android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmToken.java
...n/java/com/wix/reactnativenotifications/fcm/FcmToken.java
+3
-3
android/app/src/main/java/com/wix/reactnativenotifications/fcm/IFcmToken.java
.../java/com/wix/reactnativenotifications/fcm/IFcmToken.java
+1
-1
android/app/src/main/java/com/wix/reactnativenotifications/fcm/INotificationsFcmApplication.java
...nativenotifications/fcm/INotificationsFcmApplication.java
+7
-0
example/android/myapplication/src/main/AndroidManifest.xml
example/android/myapplication/src/main/AndroidManifest.xml
+0
-3
example/android/send_notif.py
example/android/send_notif.py
+0
-31
No files found.
android/app/build.gradle
View file @
e434c620
...
@@ -17,6 +17,25 @@ android {
...
@@ -17,6 +17,25 @@ android {
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
),
'proguard-rules.pro'
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
),
'proguard-rules.pro'
}
}
}
}
testOptions
{
unitTests
.
all
{
t
->
reports
{
html
.
enabled
true
}
testLogging
{
events
"PASSED"
,
"SKIPPED"
,
"FAILED"
,
"standardOut"
,
"standardError"
}
afterSuite
{
desc
,
result
->
if
(!
desc
.
parent
)
{
// will match the outermost suite
def
output
=
" ${result.resultType} (${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped) "
def
repeatLength
=
output
.
length
()
println
'\n\n'
+
(
'-'
*
repeatLength
)
+
'\n'
+
output
+
'\n'
+
(
'-'
*
repeatLength
)
+
'\n'
println
"see report at file://${t.reports.html.destination}/index.html"
}
}
}
}
}
}
dependencies
{
dependencies
{
...
...
android/app/src/main/AndroidManifest.xml
View file @
e434c620
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
package=
"com.wix.reactnativenotifications"
>
package=
"com.wix.reactnativenotifications"
>
<!--
<!--
Permissions required for enabling
G
CM.
Permissions required for enabling
F
CM.
-->
-->
<permission
<permission
android:name=
"${applicationId}.permission.C2D_MESSAGE"
android:name=
"${applicationId}.permission.C2D_MESSAGE"
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
<service
android:name=
".core.ProxyService"
/>
<service
android:name=
".core.ProxyService"
/>
<service
<service
android:name=
".
g
cm.FcmInstanceIdListenerService"
>
android:name=
".
f
cm.FcmInstanceIdListenerService"
>
<intent-filter>
<intent-filter>
<action
android:name=
"com.google.firebase.MESSAGING_EVENT"
/>
<action
android:name=
"com.google.firebase.MESSAGING_EVENT"
/>
<action
android:name=
"com.google.firebase.INSTANCE_ID_EVENT"
/>
<action
android:name=
"com.google.firebase.INSTANCE_ID_EVENT"
/>
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
</service>
</service>
<service
<service
android:name=
".
g
cm.FcmInstanceIdRefreshHandlerService"
android:name=
".
f
cm.FcmInstanceIdRefreshHandlerService"
android:exported=
"false"
/>
android:exported=
"false"
/>
</application>
</application>
...
...
android/app/src/main/java/com/wix/reactnativenotifications/Defs.java
View file @
e434c620
...
@@ -2,7 +2,6 @@ package com.wix.reactnativenotifications;
...
@@ -2,7 +2,6 @@ package com.wix.reactnativenotifications;
public
interface
Defs
{
public
interface
Defs
{
String
LOGTAG
=
"ReactNativeNotifs"
;
String
LOGTAG
=
"ReactNativeNotifs"
;
String
GCM_SENDER_ID_ATTR_NAME
=
"com.wix.reactnativenotifications.gcmSenderId"
;
String
TOKEN_RECEIVED_EVENT_NAME
=
"remoteNotificationsRegistered"
;
String
TOKEN_RECEIVED_EVENT_NAME
=
"remoteNotificationsRegistered"
;
...
...
android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java
View file @
e434c620
...
@@ -15,7 +15,6 @@ import com.facebook.react.bridge.ReactApplicationContext;
...
@@ -15,7 +15,6 @@ import com.facebook.react.bridge.ReactApplicationContext;
import
com.facebook.react.bridge.ReactContextBaseJavaModule
;
import
com.facebook.react.bridge.ReactContextBaseJavaModule
;
import
com.facebook.react.bridge.ReactMethod
;
import
com.facebook.react.bridge.ReactMethod
;
import
com.facebook.react.bridge.ReadableMap
;
import
com.facebook.react.bridge.ReadableMap
;
import
com.wix.reactnativenotifications.core.AppLifecycleFacade
;
import
com.wix.reactnativenotifications.core.AppLifecycleFacadeHolder
;
import
com.wix.reactnativenotifications.core.AppLifecycleFacadeHolder
;
import
com.wix.reactnativenotifications.core.InitialNotificationHolder
;
import
com.wix.reactnativenotifications.core.InitialNotificationHolder
;
import
com.wix.reactnativenotifications.core.NotificationIntentAdapter
;
import
com.wix.reactnativenotifications.core.NotificationIntentAdapter
;
...
@@ -25,9 +24,7 @@ import com.wix.reactnativenotifications.core.notification.PushNotification;
...
@@ -25,9 +24,7 @@ import com.wix.reactnativenotifications.core.notification.PushNotification;
import
com.wix.reactnativenotifications.core.notification.PushNotificationProps
;
import
com.wix.reactnativenotifications.core.notification.PushNotificationProps
;
import
com.wix.reactnativenotifications.core.notificationdrawer.IPushNotificationsDrawer
;
import
com.wix.reactnativenotifications.core.notificationdrawer.IPushNotificationsDrawer
;
import
com.wix.reactnativenotifications.core.notificationdrawer.PushNotificationsDrawer
;
import
com.wix.reactnativenotifications.core.notificationdrawer.PushNotificationsDrawer
;
import
com.wix.reactnativenotifications.gcm.FcmInstanceIdRefreshHandlerService
;
import
com.wix.reactnativenotifications.fcm.FcmInstanceIdRefreshHandlerService
;
import
com.google.firebase.FirebaseApp
;
import
static
com
.
wix
.
reactnativenotifications
.
Defs
.
LOGTAG
;
import
static
com
.
wix
.
reactnativenotifications
.
Defs
.
LOGTAG
;
...
@@ -50,7 +47,7 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements
...
@@ -50,7 +47,7 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements
@Override
@Override
public
void
initialize
()
{
public
void
initialize
()
{
Log
.
d
(
LOGTAG
,
"Native module init"
);
Log
.
d
(
LOGTAG
,
"Native module init"
);
start
G
cmIntentService
(
FcmInstanceIdRefreshHandlerService
.
EXTRA_IS_APP_INIT
);
start
F
cmIntentService
(
FcmInstanceIdRefreshHandlerService
.
EXTRA_IS_APP_INIT
);
final
IPushNotificationsDrawer
notificationsDrawer
=
PushNotificationsDrawer
.
get
(
getReactApplicationContext
().
getApplicationContext
());
final
IPushNotificationsDrawer
notificationsDrawer
=
PushNotificationsDrawer
.
get
(
getReactApplicationContext
().
getApplicationContext
());
notificationsDrawer
.
onAppInit
();
notificationsDrawer
.
onAppInit
();
...
@@ -75,7 +72,7 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements
...
@@ -75,7 +72,7 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements
@ReactMethod
@ReactMethod
public
void
refreshToken
()
{
public
void
refreshToken
()
{
Log
.
d
(
LOGTAG
,
"Native method invocation: refreshToken()"
);
Log
.
d
(
LOGTAG
,
"Native method invocation: refreshToken()"
);
start
G
cmIntentService
(
FcmInstanceIdRefreshHandlerService
.
EXTRA_MANUAL_REFRESH
);
start
F
cmIntentService
(
FcmInstanceIdRefreshHandlerService
.
EXTRA_MANUAL_REFRESH
);
}
}
@ReactMethod
@ReactMethod
...
@@ -115,7 +112,7 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements
...
@@ -115,7 +112,7 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements
promise
.
resolve
(
new
Boolean
(
hasPermission
));
promise
.
resolve
(
new
Boolean
(
hasPermission
));
}
}
protected
void
start
G
cmIntentService
(
String
extraFlag
)
{
protected
void
start
F
cmIntentService
(
String
extraFlag
)
{
final
Context
appContext
=
getReactApplicationContext
().
getApplicationContext
();
final
Context
appContext
=
getReactApplicationContext
().
getApplicationContext
();
final
Intent
tokenFetchIntent
=
new
Intent
(
appContext
,
FcmInstanceIdRefreshHandlerService
.
class
);
final
Intent
tokenFetchIntent
=
new
Intent
(
appContext
,
FcmInstanceIdRefreshHandlerService
.
class
);
tokenFetchIntent
.
putExtra
(
extraFlag
,
true
);
tokenFetchIntent
.
putExtra
(
extraFlag
,
true
);
...
...
android/app/src/main/java/com/wix/reactnativenotifications/
g
cm/FcmInstanceIdListenerService.java
→
android/app/src/main/java/com/wix/reactnativenotifications/
f
cm/FcmInstanceIdListenerService.java
View file @
e434c620
package
com.wix.reactnativenotifications.
g
cm
;
package
com.wix.reactnativenotifications.
f
cm
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.util.Log
;
...
@@ -8,12 +8,10 @@ import com.google.firebase.messaging.RemoteMessage;
...
@@ -8,12 +8,10 @@ import com.google.firebase.messaging.RemoteMessage;
import
com.wix.reactnativenotifications.core.notification.IPushNotification
;
import
com.wix.reactnativenotifications.core.notification.IPushNotification
;
import
com.wix.reactnativenotifications.core.notification.PushNotification
;
import
com.wix.reactnativenotifications.core.notification.PushNotification
;
import
java.util.Map
;
import
static
com
.
wix
.
reactnativenotifications
.
Defs
.
LOGTAG
;
import
static
com
.
wix
.
reactnativenotifications
.
Defs
.
LOGTAG
;
/**
/**
* Instance-ID + token refreshing handling service. Contacts the
G
CM to fetch the updated token.
* Instance-ID + token refreshing handling service. Contacts the
F
CM to fetch the updated token.
*
*
* @author amitd
* @author amitd
*/
*/
...
@@ -22,14 +20,14 @@ public class FcmInstanceIdListenerService extends FirebaseMessagingService {
...
@@ -22,14 +20,14 @@ public class FcmInstanceIdListenerService extends FirebaseMessagingService {
@Override
@Override
public
void
onMessageReceived
(
RemoteMessage
message
){
public
void
onMessageReceived
(
RemoteMessage
message
){
Bundle
bundle
=
message
.
toIntent
().
getExtras
();
Bundle
bundle
=
message
.
toIntent
().
getExtras
();
Log
.
d
(
LOGTAG
,
"New message from
G
CM: "
+
bundle
);
Log
.
d
(
LOGTAG
,
"New message from
F
CM: "
+
bundle
);
try
{
try
{
final
IPushNotification
notification
=
PushNotification
.
get
(
getApplicationContext
(),
bundle
);
final
IPushNotification
notification
=
PushNotification
.
get
(
getApplicationContext
(),
bundle
);
notification
.
onReceived
();
notification
.
onReceived
();
}
catch
(
IPushNotification
.
InvalidNotificationException
e
)
{
}
catch
(
IPushNotification
.
InvalidNotificationException
e
)
{
// A
G
CM message, yes - but not the kind we know how to work with.
// A
n F
CM message, yes - but not the kind we know how to work with.
Log
.
v
(
LOGTAG
,
"
G
CM message handling aborted"
,
e
);
Log
.
v
(
LOGTAG
,
"
F
CM message handling aborted"
,
e
);
}
}
}
}
}
}
android/app/src/main/java/com/wix/reactnativenotifications/
g
cm/FcmInstanceIdRefreshHandlerService.java
→
android/app/src/main/java/com/wix/reactnativenotifications/
f
cm/FcmInstanceIdRefreshHandlerService.java
View file @
e434c620
package
com.wix.reactnativenotifications.
g
cm
;
package
com.wix.reactnativenotifications.
f
cm
;
import
android.app.IntentService
;
import
android.app.IntentService
;
import
android.content.Intent
;
import
android.content.Intent
;
...
@@ -14,17 +14,17 @@ public class FcmInstanceIdRefreshHandlerService extends IntentService {
...
@@ -14,17 +14,17 @@ public class FcmInstanceIdRefreshHandlerService extends IntentService {
@Override
@Override
protected
void
onHandleIntent
(
Intent
intent
)
{
protected
void
onHandleIntent
(
Intent
intent
)
{
IFcmToken
g
cmToken
=
FcmToken
.
get
(
this
);
IFcmToken
f
cmToken
=
FcmToken
.
get
(
this
);
if
(
g
cmToken
==
null
)
{
if
(
f
cmToken
==
null
)
{
return
;
return
;
}
}
if
(
intent
.
getBooleanExtra
(
EXTRA_IS_APP_INIT
,
false
))
{
if
(
intent
.
getBooleanExtra
(
EXTRA_IS_APP_INIT
,
false
))
{
g
cmToken
.
onAppReady
();
f
cmToken
.
onAppReady
();
}
else
if
(
intent
.
getBooleanExtra
(
EXTRA_MANUAL_REFRESH
,
false
))
{
}
else
if
(
intent
.
getBooleanExtra
(
EXTRA_MANUAL_REFRESH
,
false
))
{
g
cmToken
.
onManualRefresh
();
f
cmToken
.
onManualRefresh
();
}
else
{
}
else
{
g
cmToken
.
onNewTokenReady
();
f
cmToken
.
onNewTokenReady
();
}
}
}
}
}
}
android/app/src/main/java/com/wix/reactnativenotifications/
g
cm/FcmToken.java
→
android/app/src/main/java/com/wix/reactnativenotifications/
f
cm/FcmToken.java
View file @
e434c620
package
com.wix.reactnativenotifications.
g
cm
;
package
com.wix.reactnativenotifications.
f
cm
;
import
android.content.Context
;
import
android.content.Context
;
import
android.util.Log
;
import
android.util.Log
;
...
@@ -29,8 +29,8 @@ public class FcmToken implements IFcmToken {
...
@@ -29,8 +29,8 @@ public class FcmToken implements IFcmToken {
public
static
IFcmToken
get
(
Context
context
)
{
public
static
IFcmToken
get
(
Context
context
)
{
Context
appContext
=
context
.
getApplicationContext
();
Context
appContext
=
context
.
getApplicationContext
();
if
(
appContext
instanceof
INotifications
G
cmApplication
)
{
if
(
appContext
instanceof
INotifications
F
cmApplication
)
{
return
((
INotifications
G
cmApplication
)
appContext
).
getFcmToken
(
context
);
return
((
INotifications
F
cmApplication
)
appContext
).
getFcmToken
(
context
);
}
}
return
new
FcmToken
(
appContext
);
return
new
FcmToken
(
appContext
);
}
}
...
...
android/app/src/main/java/com/wix/reactnativenotifications/
g
cm/IFcmToken.java
→
android/app/src/main/java/com/wix/reactnativenotifications/
f
cm/IFcmToken.java
View file @
e434c620
package
com.wix.reactnativenotifications.
g
cm
;
package
com.wix.reactnativenotifications.
f
cm
;
public
interface
IFcmToken
{
public
interface
IFcmToken
{
...
...
android/app/src/main/java/com/wix/reactnativenotifications/
gcm/INotificationsG
cmApplication.java
→
android/app/src/main/java/com/wix/reactnativenotifications/
fcm/INotificationsF
cmApplication.java
View file @
e434c620
package
com.wix.reactnativenotifications.
g
cm
;
package
com.wix.reactnativenotifications.
f
cm
;
import
android.content.Context
;
import
android.content.Context
;
public
interface
INotifications
G
cmApplication
{
public
interface
INotifications
F
cmApplication
{
IFcmToken
getFcmToken
(
Context
context
);
IFcmToken
getFcmToken
(
Context
context
);
}
}
example/android/myapplication/src/main/AndroidManifest.xml
View file @
e434c620
...
@@ -12,9 +12,6 @@
...
@@ -12,9 +12,6 @@
android:usesCleartextTraffic=
"true"
android:usesCleartextTraffic=
"true"
android:label=
"@string/app_name"
android:label=
"@string/app_name"
android:theme=
"@style/AppTheme"
>
android:theme=
"@style/AppTheme"
>
<meta-data
android:name=
"com.wix.reactnativenotifications.gcmSenderId"
android:value=
"434691868895\0"
/>
<activity
<activity
android:name=
".MainActivity"
android:name=
".MainActivity"
...
...
example/android/send_notif.py
deleted
100755 → 0
View file @
b4030449
#!/usr/bin/python
from
urllib2
import
*
import
json
import
sys
if
len
(
sys
.
argv
)
<
2
:
print
'Error: missing token argument'
sys
.
exit
(
1
)
API_KEY
=
'AIzaSyBVtqdO_SgPVhhXnyNGC_VXSbIX-fxk1YY'
TOKEN
=
sys
.
argv
[
1
]
data
=
{
"to"
:
TOKEN
,
"data"
:
{
"body"
:
"SUCCESS! Sent from script :)"
,
"title"
:
"Wix Example Project"
}
}
dataJson
=
json
.
dumps
(
data
)
request
=
Request
(
'https://gcm-http.googleapis.com/gcm/send'
,
dataJson
,
{
"Authorization"
:
"key="
+
API_KEY
,
"Content-type"
:
"application/json"
}
)
print
"Sending notification..."
print
urlopen
(
request
).
read
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment