Hi,
I've already asked this question in a related project several days ago, but didn't get any reply yet. It's a bit of a showstopper at the moment, so decided to try my luck to get more attention in here :)
Calling ng component method from receive broadcaster
https://github.com/NativeScript/sample-android-background-services/issues/5
P.S.: I know I'm learning NS a bit backwards. As first the project I decided to make an app that reads, listens to and sends sms. That made me immediately step into the native land :) Had to implement own (android) plugin that sends sms directly (without opening an external app), find a bug in NS background services example project etc. Right at this moment googling anything related to native, broadcaster usage etc. doesn't yield any good results for NS, of course this will change in near future :)
@snekbaev there is no need to open multiple issues regarding a single problem. We monitor all repositories, and reply as soon as possible. Closing this issue in favor of the one opened previously in the sample repo. We can discuss the issue there.
Hey @snekbaev
You can use this sample app as a reference for NativeScript + Angular-2 examles.
One of the examples is covering the usage of Android broadcast receiver.
Basically, Yes you can follow your logic and register the receiver onInit and unregister on ngDestroy (if that is the best scenario based on your logic)
@Pip3r4o I understand the frustration regarding multiple issues about the same thing. But let me try to elaborate my actions.
Yes, issue 5 was created on late Thursday. I struggled with it before asking for some time though. I continued working on other stuff on Friday and over the weekend. So from my point it is several days already, and as a developer you know when you get stuck with something what it is like to wait in case of a showstopper*. In addition, I didn't know how long more would I have to wait. Of course, I don't expect one to be available on the weekend, but that sometimes happens, like you replying to my other issue 4 on Sunday, which is still open by the way.
Now by asking in the main repo I reached out to more people, received an immediate response which actually solved the issue. Thank you @NickIliev !
Also this really suggests just to use the main repo to ask questions instead of the other NS repositories corresponding to the actual issue :)
All in all, I'm sorry for the inconvenience caused, however, now I can actually continue with the evaluation of NS :)
Thank you guys!
*on top of that I got confused about native android implementation SO questions where one had to pass the Activity's reference into a custom Broadcast receiver class. I was about to attempt to extract the internals of the tns-core-modules\application\application.android.js, but then it just felt that probably I'm doing something really unnecessary and decided to put efforts into something tangible. For example, one of the things were to upgrade the project to 2.4, which didn't go smooth: tns update failed to re-add my own plugin from the disk (besides some other issues and warnings), so by googling somewhat managed to upgrade to 2.4 including the npm dependencies with the correct versions, yet feels like I did something wrong, because apk file is larger now (+4 megs) and it takes longer to start on N5 compared to 2.3 . I need to investigate this further.
@snekbaev thanks for reaching out to us with this feedback. No inconvenience or frustration caused, just trying to keep things clean around here. As for your other issue, I will reply back to you as soon as time allows it.
As for updating to 2.4 and the size concerns - what you are experiencing is indeed abnormal. If anything, the size of the final APK should be smaller. Feel free to create an issue in the android-runtime repository with as much details of the upgrade process as possible, including installed packages, commands used, etc. so that we may investigate the matter.
Thank you! You guys are awesome! :)
Incoming sms BroadcastReceiver on receive method is not working..
android.content.BroadcastReceiver.extend("com.broadcastreceivers.IncomingSmsBroadcastReceiver", {
onReceive: function(context, intent) {
console.log("send",com.broadcastreceivers.IncomingSmsBroadcastReceiver);
var messages= intent.getSerializableExtra("pdus");
var format=intent.getStringExtra("format");
console.log("smsmanage",messages);
console.log("smsmanagerformat",format);
}
});
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Hey @snekbaev
You can use this sample app as a reference for NativeScript + Angular-2 examles.
One of the examples is covering the usage of Android broadcast receiver.
Basically, Yes you can follow your logic and register the receiver onInit and unregister on ngDestroy (if that is the best scenario based on your logic)