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
a74aedd3
Commit
a74aedd3
authored
Dec 20, 2016
by
Baldur Páll Hólmgeirsson
Committed by
Libin Lu
Dec 20, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support bitmap urls in large-icon (#238)
* Support bitmap urls in large-icon * Remove comment
parent
818f9659
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
5 deletions
+28
-5
android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java
...in/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java
+28
-5
No files found.
android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java
View file @
a74aedd3
...
@@ -16,12 +16,16 @@ import android.os.Build;
...
@@ -16,12 +16,16 @@ import android.os.Build;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.support.v4.app.NotificationCompat
;
import
android.support.v4.app.NotificationCompat
;
import
android.util.Log
;
import
android.util.Log
;
import
android.util.Patterns
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URL
;
import
java.net.HttpURLConnection
;
public
class
FIRLocalMessagingHelper
{
public
class
FIRLocalMessagingHelper
{
private
static
final
long
DEFAULT_VIBRATION
=
300L
;
private
static
final
long
DEFAULT_VIBRATION
=
300L
;
...
@@ -110,6 +114,10 @@ public class FIRLocalMessagingHelper {
...
@@ -110,6 +114,10 @@ public class FIRLocalMessagingHelper {
//large icon
//large icon
String
largeIcon
=
bundle
.
getString
(
"large-icon"
);
String
largeIcon
=
bundle
.
getString
(
"large-icon"
);
if
(
largeIcon
!=
null
&&
android
.
os
.
Build
.
VERSION
.
SDK_INT
>=
android
.
os
.
Build
.
VERSION_CODES
.
LOLLIPOP
){
if
(
largeIcon
!=
null
&&
android
.
os
.
Build
.
VERSION
.
SDK_INT
>=
android
.
os
.
Build
.
VERSION_CODES
.
LOLLIPOP
){
if
(
largeIcon
.
startsWith
(
"http://"
)
||
largeIcon
.
startsWith
(
"https://"
))
{
Bitmap
bitmap
=
getBitmapFromURL
(
largeIcon
);
notification
.
setLargeIcon
(
bitmap
);
}
else
{
int
largeIconResId
=
res
.
getIdentifier
(
largeIcon
,
"mipmap"
,
packageName
);
int
largeIconResId
=
res
.
getIdentifier
(
largeIcon
,
"mipmap"
,
packageName
);
Bitmap
largeIconBitmap
=
BitmapFactory
.
decodeResource
(
res
,
largeIconResId
);
Bitmap
largeIconBitmap
=
BitmapFactory
.
decodeResource
(
res
,
largeIconResId
);
...
@@ -117,6 +125,7 @@ public class FIRLocalMessagingHelper {
...
@@ -117,6 +125,7 @@ public class FIRLocalMessagingHelper {
notification
.
setLargeIcon
(
largeIconBitmap
);
notification
.
setLargeIcon
(
largeIconBitmap
);
}
}
}
}
}
//big text
//big text
String
bigText
=
bundle
.
getString
(
"big_text"
);
String
bigText
=
bundle
.
getString
(
"big_text"
);
...
@@ -303,4 +312,18 @@ public class FIRLocalMessagingHelper {
...
@@ -303,4 +312,18 @@ public class FIRLocalMessagingHelper {
public
void
setApplicationForeground
(
boolean
foreground
){
public
void
setApplicationForeground
(
boolean
foreground
){
mIsForeground
=
foreground
;
mIsForeground
=
foreground
;
}
}
public
Bitmap
getBitmapFromURL
(
String
strURL
)
{
try
{
URL
url
=
new
URL
(
strURL
);
HttpURLConnection
connection
=
(
HttpURLConnection
)
url
.
openConnection
();
connection
.
setDoInput
(
true
);
connection
.
connect
();
InputStream
input
=
connection
.
getInputStream
();
return
BitmapFactory
.
decodeStream
(
input
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
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