Comments (13)
I am entrepreneur and I need that things works. Then I look at revenue. I just said how to make things work.
Doesn't look like a good strategy to generate long-term revenue tbh. Beware of the day when all of this falls on your feet and you're in full fire fighting mode :-P But you do you ...
@alexd2580-sf: I'm currently working on a different project, but if I get back to this one, I might submit the PR. But can't say how long until then, so if you need it, go ahead ;-)
from capacitor-plugins.
http/https urls are not supported by iOS (native API limitation)
on Android and Web the attachments are not shown as images, should be implemented
from capacitor-plugins.
If someone wants to show big image with notification then you need to add this code at line 185 in LocalNotificationManager.java:
if (localNotification.getAttachments() != null) {
mBuilder.setStyle(
new NotificationCompat.BigPictureStyle()
.bigPicture(localNotification.getBigImage(context))
);
}
And this code at line 386 in LocalNotifications.java:
import android.net.Uri;
...
public Bitmap getBigImage(Context context) {
if (attachments != null && attachments.size() > 0) {
try {
LocalNotificationAttachment bp = attachments.get(0);
String bpUrl = bp.getUrl();
final AssetUtil assets = AssetUtil.getInstance(context);
Uri uri = assets.parse(bpUrl);
if (uri != Uri.EMPTY) {
return assets.getIconFromUri(uri);
}
} catch (Exception e){
e.printStackTrace();
}
}
return null;
}
And also you need to fix a bug in a capacitor file
node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/util/AssetUtil.java
at line 328:
change from
String authority = context.getPackageName() + ".provider";
to
String authority = context.getPackageName() + ".fileprovider";
And at line 106:
change from
String resPath = path.replaceFirst("file:/", "www").replaceFirst("\\?.*$", "");
to
String resPath = path.replaceFirst("file:/", "public").replaceFirst("\\?.*$", "");
Then these links (url: 'file://assets/notifications/preview.jpg'
) will work in your javascript scheduling code:
{
id: 666,
largeIcon: bigIcon,
schedule: { at: rem },
title: title,
body: text,
largeBody: text,
attachments: [{ id: 'my_preview', url: 'file://assets/notifications/preview.jpg' }]
}
Also that plugin architecture is too ill-considered and I see error !!! FAILED BINDER TRANSACTION !!! when load standard images that worked fine with katzer plugin.
In order to fix somehow, I added compression in capacitor file
node_modules/@capacitor/android/capacitor/src/main/java/com/getcapacitor/plugin/util/AssetUtil.java
at line 259:
InputStream stream = context.getContentResolver().openInputStream(uri);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.RGB_565;
return BitmapFactory.decodeStream(stream, null, options);
Instead of that:
InputStream input = context.getContentResolver().openInputStream(uri);
return BitmapFactory.decodeStream(input);
P.S.: But bigImage should be no more then 512x256 and largeIcon no more then 256x256
from capacitor-plugins.
Is there any sensible progress on this issue?
from capacitor-plugins.
So I need to fork the repo and build my own version of the plugin you say? That's something I tried to avoid tbh because I'm not that much into Java. Would you care to submit your code as a PR to this repo in order to fix the issue / add this feature?
from capacitor-plugins.
@frederikheld I edited code directly in node_modules.
All you need - it's just pass base64 string via any property and convert it with java code:
byte[] decodedString = Base64.decode(base64ImageString, Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
return decodedByte;
from capacitor-plugins.
Editing the code directly in node_modules is the worst advice you could give to anyone who tries to write software on a level that is above script kiddie 😖 How would you deal with updates? How would you make that portable? How would you make it reproducible? The whole point of packaging systems like npm is to only share a list of well defined dependencies which makes it easy to update, move around and reproduce. Fiddling around in node_modules breaks all of this...
from capacitor-plugins.
i think attachments is not work for android.... for android you can use "largeIcon:" property to show your image first copy your image in res/drawable
folder (not in 'res' only) and then write the name of your image in largeIcon........for example:
i copy my 'manager.png' in 'android\app\src\main\res\drawable'
then in my code:
LocalNotifications.schedule({
notifications: [
{
title: 'the title',
body: 'msg body',
id: 1,
largeIcon:'manager',
smallIcon:'manager'
}
]
});
it's look small but i think it much better than nothing.....
from capacitor-plugins.
for android you can use "largeIcon:" property to show your image first copy your image in
res/drawable
folder (not in 'res' only) and then write the name of your image in largeIcon.
Is there any way to use a base64 encoded image from a variable instead? I'd like to display a profile picture as largeImage
that was previously uploaded by the user and stored in Vuex as a bas64 encoded string.
from capacitor-plugins.
@frederikheld yes. Just edit the source code like I did for bigImage.
from capacitor-plugins.
But apart from that: your code only needs some if clause that checks what image format is incoming in order to make it compatible with the current source, then you could submit it as a pull request so it could go into the package in the regular way. I would appreciate that very much!
from capacitor-plugins.
@frederikheld I am entrepreneur and I need that things works. Then I look at revenue. I just said how to make things work. I really want to make PR but I have no time...
from capacitor-plugins.
How would you deal with updates? How would you make that portable? How would you make it reproducible?
Actually, there's an easy way with e.g. pnpm, you have the patch
command. So you can make changes to modules that get applied as a patch every time (reproducible) even with updates, yet are stored locally in your project (portable).
from capacitor-plugins.
Related Issues (20)
- Please provide marker rotation in google maps plugin HOT 2
- [splash-screen] Make docs usable for iOS app HOT 2
- Cannot select a printer from the Share dialogue box HOT 1
- bug(@capacitor/share): FATAL EXCEPTION java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tvoydnevnik/com.tvoydnevnik.MainActivity}: java.lang.SecurityException: com.tvoydnevnik: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts HOT 2
- Add Capacitor Webview HOT 2
- Add map events to be handled at client side HOT 2
- Complience with Apples Required Reason API HOT 18
- google.maps.Marker is deprecated HOT 1
- [Geolocation / Android] The GPS position is only updated every 5 seconds when using "watchPosition" function on Android HOT 1
- [Bug]: @capacitor/camera - Console (F12) error (undefined) clicking on the camera icon when still loading the camera or not alowing the permission yet. HOT 3
- [Feature] Deep linking for Chromebook Android (App appUrlOpen)
- @capacitor/share not work in android 14, capacitor 6 HOT 4
- [Bug]: @capacitor/camera - After taking a photo (web), a certain border around the photo is cut away. HOT 4
- [Bug]: @capacitor/camera - After turning the device from landscape to portrait, the wrong modes are used when taking a photo. HOT 3
- feat(@capacitor/device) Request to update device plugin to remove privacy-impacting APIs HOT 1
- @capacitor/browser add a new BROWSER_CLOSED event HOT 1
- [@capacitor/filesystem] Successful Filesystem.requestPermissions prompt never resolves due to missing case in callback HOT 5
- [Feature]: native camera max weight settings
- @capacitor/share not working with capacitor v6 HOT 2
- Filesystem.copy not working con content:/ android
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from capacitor-plugins.