Browse Source

Fix notification value for android download Manager

Vikas Kapadiya 6 years ago
parent
commit
521e0c4cee
2 changed files with 6 additions and 2 deletions
  1. 1
    1
      README.md
  2. 5
    1
      android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java

+ 1
- 1
README.md View File

120
     <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
120
     <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
121
 +   <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />                                               
121
 +   <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />                                               
122
 +   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />                                              
122
 +   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />                                              
123
-
123
++   <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
124
     ...
124
     ...
125
 
125
 
126
 ```
126
 ```

+ 5
- 1
android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java View File

161
             if (options.addAndroidDownloads.getBoolean("useDownloadManager")) {
161
             if (options.addAndroidDownloads.getBoolean("useDownloadManager")) {
162
                 Uri uri = Uri.parse(url);
162
                 Uri uri = Uri.parse(url);
163
                 DownloadManager.Request req = new DownloadManager.Request(uri);
163
                 DownloadManager.Request req = new DownloadManager.Request(uri);
164
-                req.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
164
+                if(options.addAndroidDownloads.getBoolean("notification")) {
165
+                    req.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
166
+                } else {
167
+                    req.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);
168
+                }
165
                 if(options.addAndroidDownloads.hasKey("title")) {
169
                 if(options.addAndroidDownloads.hasKey("title")) {
166
                     req.setTitle(options.addAndroidDownloads.getString("title"));
170
                     req.setTitle(options.addAndroidDownloads.getString("title"));
167
                 }
171
                 }