Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
react-native-fcm
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
ym
react-native-fcm
Commits
0d0b0eae
Commit
0d0b0eae
authored
Jan 03, 2018
by
Libin Lu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add wake_screen
parent
3877ad8a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
6 deletions
+18
-6
Examples/simple-fcm-client/android/app/src/main/AndroidManifest.xml
...imple-fcm-client/android/app/src/main/AndroidManifest.xml
+1
-0
Examples/simple-fcm-client/app/App.js
Examples/simple-fcm-client/app/App.js
+2
-1
android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java
.../main/java/com/evollu/react/fcm/SendNotificationTask.java
+15
-5
No files found.
Examples/simple-fcm-client/android/app/src/main/AndroidManifest.xml
View file @
0d0b0eae
...
...
@@ -7,6 +7,7 @@
<uses-permission
android:name=
"android.permission.SYSTEM_ALERT_WINDOW"
/>
<uses-permission
android:name=
"android.permission.RECEIVE_BOOT_COMPLETED"
/>
<uses-permission
android:name=
"android.permission.VIBRATE"
/>
<uses-permission
android:name=
"android.permission.WAKE_LOCK"
/>
<uses-sdk
android:minSdkVersion=
"16"
...
...
Examples/simple-fcm-client/app/App.js
View file @
0d0b0eae
...
...
@@ -83,7 +83,8 @@ export default class App extends Component {
priority
:
"
high
"
,
large_icon
:
"
https://image.freepik.com/free-icon/small-boy-cartoon_318-38077.jpg
"
,
show_in_foreground
:
true
,
picture
:
'
https://firebase.google.com/_static/af7ae4b3fc/images/firebase/lockup.png
'
picture
:
'
https://firebase.google.com/_static/af7ae4b3fc/images/firebase/lockup.png
'
,
wake_screen
:
true
});
}
...
...
android/src/main/java/com/evollu/react/fcm/SendNotificationTask.java
View file @
0d0b0eae
...
...
@@ -15,6 +15,7 @@ import android.net.Uri;
import
android.os.AsyncTask
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.PowerManager
;
import
android.support.v4.app.NotificationCompat
;
import
android.support.v4.app.NotificationManagerCompat
;
import
android.support.v4.content.LocalBroadcastManager
;
...
...
@@ -35,7 +36,7 @@ public class SendNotificationTask extends AsyncTask<Void, Void, Void> {
private
SharedPreferences
sharedPreferences
;
private
Boolean
mIsForeground
;
public
SendNotificationTask
(
Context
context
,
SharedPreferences
sharedPreferences
,
Boolean
mIsForeground
,
Bundle
bundle
){
SendNotificationTask
(
Context
context
,
SharedPreferences
sharedPreferences
,
Boolean
mIsForeground
,
Bundle
bundle
){
this
.
mContext
=
context
;
this
.
bundle
=
bundle
;
this
.
sharedPreferences
=
sharedPreferences
;
...
...
@@ -215,6 +216,16 @@ public class SendNotificationTask extends AsyncTask<Void, Void, Void> {
NotificationManagerCompat
.
from
(
mContext
).
notify
(
notificationID
,
info
);
}
if
(
bundle
.
getBoolean
(
"wake_screen"
,
false
)){
PowerManager
pm
=
(
PowerManager
)
mContext
.
getSystemService
(
Context
.
POWER_SERVICE
);
if
(
pm
!=
null
&&
!
pm
.
isScreenOn
())
{
PowerManager
.
WakeLock
wl
=
pm
.
newWakeLock
(
PowerManager
.
FULL_WAKE_LOCK
|
PowerManager
.
ACQUIRE_CAUSES_WAKEUP
|
PowerManager
.
ON_AFTER_RELEASE
,
"FCMLock"
);
wl
.
acquire
(
5000
);
}
}
//clear out one time scheduled notification once fired
if
(!
bundle
.
containsKey
(
"repeat_interval"
)
&&
bundle
.
containsKey
(
"fire_date"
))
{
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
...
...
@@ -227,7 +238,7 @@ public class SendNotificationTask extends AsyncTask<Void, Void, Void> {
return
null
;
}
p
ublic
Bitmap
getBitmapFromURL
(
String
strURL
)
{
p
rivate
Bitmap
getBitmapFromURL
(
String
strURL
)
{
try
{
URL
url
=
new
URL
(
strURL
);
HttpURLConnection
connection
=
(
HttpURLConnection
)
url
.
openConnection
();
...
...
@@ -241,11 +252,10 @@ public class SendNotificationTask extends AsyncTask<Void, Void, Void> {
}
}
p
ublic
String
getMainActivityClassName
()
{
p
rotected
String
getMainActivityClassName
()
{
String
packageName
=
mContext
.
getPackageName
();
Intent
launchIntent
=
mContext
.
getPackageManager
().
getLaunchIntentForPackage
(
packageName
);
String
className
=
launchIntent
.
getComponent
().
getClassName
();
return
className
;
return
launchIntent
!=
null
?
launchIntent
.
getComponent
().
getClassName
()
:
null
;
}
}
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