Cordova Tools for Visual Studio - PushNotification has no method init - azure-mobile-services

I'm trying to create a Cordova app in Visual Studio that will receive push notifications from Azure Mobile Services. I'm using this plugin: https://github.com/phonegap/phonegap-plugin-push/
I installed it by opening the config -> Plugins -> Custom and putting in the above GitHub address. It installs fine, but I must be missing something, because this code doesn't work:
document.addEventListener('deviceready', function () {
mobileServiceClient = new WindowsAzure.MobileServiceClient(
'AZURE_MOBILE_URL',
'MY_API_KEY');
// Create a new PushNotification and start registration with the PNS.
var pushNotification = PushNotification.init({
"android": { "senderID": MY_SEND£ER_ID}
});
Running in the Goolgle Android Emulator, it says that init is not a function.

Sounds as if the plug-in didn't install correctly. I've often deleted my whole project and re got the source code then add the plug-in again
Also sometimes getting a local copy of the plug-in helps

Related

Android Studio not creating main.dart file

I'm new to programming so please be genetle. I'm handy with computers though and I've been sitting on this problem for a few weeks while learning flutter and dart
When I create a new flutter application in android studio, it does not create a main.dart file - the libs foder is empty, and I also see no IOS folder. In fact, what I see looks VERY different from any tutorials I've seen !!
What I do see is a bunh of .xml files, including one called activity main which runs a main activity function which almost seems like it is there instead of the main.dart file I'm looking for.
I have run flutter doctor, apparently everything is good.I have the dart and futter plugins installed. It is not a case of selecting "project" from the drop down menu instead of "Android" which is a common answer online. Not sure what I'm missing !!
Any help would be really really appreciated as I'm learning to code to open my next business and I am struggling to get over the first hurdle.... at leasr I am proficient wit dartpad now though :P
EDIT:
When I click on 'file > new > new flutter project', I don't see an option for "flutter application". This is what I see...
enter image description here
If I create a flutter project at this point, this is what Android Studio looks like for me...
enter image description here
If you have properly created a Flutter project in Android studio, main.dart file should be very easy to locate. It is located in project_name -> lib -> main.dart, as follows:
I am sharing steps to create flutter project in android studio :
Step 1: Open the IDE and select Start a new Flutter project.
Step 2: Select the Flutter Application as the project type. Then click Next.
Step 3: Verify the Flutter SDK path specifies the SDK’s location (select Install SDK… if the text field is blank).
Step 4: Enter a project name (for example, myapp). Then click Next.
Step 5: Click Finish.
Step 6: Wait for Android Studio to install the SDK and create the project.
Note: When creating a new Flutter app, some Flutter IDE plugins ask for a company domain name in reverse order, something like com.example. The company domain name and project name are used together as the package name for Android (the Bundle ID for iOS) when the app is released. If you think that the app might be released, it’s better to specify the package name now. The package name can’t be changed once the app is released, so make the name unique.
The above steps create a Flutter project directory called flutter_app that contains a simple demo app that uses Material Components.
Running the application:
Follow the below steps to run the flutter application that was structured above:
Step 1: Locate the main Android Studio toolbar:
Step 2: In the target selector, select an Android device for running the app. If none are listed as available, select Tools> Android > AVD Manager and create one there. For details, see Managing AVDs.
Step 3: Click the run icon in the toolbar, or invoke the menu item Run > Run.
After the app build completes, you’ll see the starter app on your device.
as per screen shot shared by you click on flutter , hopefully this will create a new flutter project.

ionic custom plugin and its wrapper issue-ionic 3,4+

I have followed this below vlog completely and was able to create custom plugin and its wrapper and was able to successfully use in ionic v3, and 4+, but after installing the .apk file on device, I get to see error as "Plugin not found".
Please help with the guidance if any. check the below link for that vlog :
Part 1-ionic wrapper creation tutorial
Part 2-[ionic wrapper creation tutorial][2]
Screenshot of after installation of apk- "plugin not found" issue on device
[1]: https://www.youtube.com/watch?v=w9zYXelkl6I&list=PLiuv1WieXgPf4cjcGfQU-IrSX2_3CkWE_&index=25
[2]: https://www.youtube.com/watch?v=Q6PaFEDonac&list=PLiuv1WieXgPf4cjcGfQU-IrSX2_3CkWE_&index=25

Extension warning in VS code

I get this warning when opening a fresh-new NativeScript (Angular) in VS code.
The below 1 extension(s) in workspace recommendations have issues: telerik.nativescript (not found in marketplace)
Should I ignore the warning or delete telerik.nativescript in the extension.json while I develop the app?
I have also been getting this notification wondering what it was after creating a new NativeScript Angular project. It seems like NativeScript is trying to recommend their NativeScript extension in VSCode https://nativescript.org/nativescript-for-visual-studio-code/.
I don't have this recommendation or extensions.json file on my older projects so I'm sure you can delete the file/recommendations and decide for yourself if you want to install their extension without affecting your project.
{
"recommendations": []
}
I think that this extension was probably renamed from "telerik.nativescript" to "NativeScript.nativescript" because in my case:
I was having the same problem described above "not found in marketplace"
I had an (old) nativescript extension already installed on my system (probably installed a year ago)
The VSCODE was kind of confused... checking the installed extensions was pointing me to the new one, but at the same time was telling me that it was not installed!?
Solution:
VSCODE: Extensions: NativeScript => [Unistall] followed by a [Install]
Source Code: "recommendations" changed "telerik.nativescript" to "NativeScript.nativescript"
Now everything seems to be in order.
Just to add some more detail, the file that needs to be changed in your NativeScript projects is ".vscode\extensions.json"
The code needs to be changed from:
{
"recommendations": [
"telerik.nativescript"
]
}
To:
{
"recommendations": [
"NativeScript.nativescript"
]
}
#antseq is correct that the extension was renamed from "telerik.nativescript" to "NativeScript.nativescript".

Flutter - 3rd party JAR code will run from within Android Studio but not from VS Code

I'm using VS Code to develop a test flutter app that uses Symbol/Zebra's EMDK to interact with a barcode scanner. This involves some custom code on the Android side, which has been implemented, and if I open the Android code within Android Studio and run it on my device everything works fine, but if I then go back to my VS Code and try to run the flutter project I get an error "Unfortunately app has stopped". I suspect this is more of an issue around the 3rd part JAR file not being included when run from the VS code side, but I'm not familiar enough with where I need to include it (Gradle, IML files) in order to make it work. Any help would be appreciated.
You can create a libs folder, for example, which should be at android/libs and place your jar file there. Then add the following to your android/build.gradle file at the bottom:
dependencies {
implementation fileTree(include: '*.jar', dir: 'libs')
}

Ionic 1 local notification not working in Ionic View app

So I'm using this plugin (https://github.com/katzer/cordova-plugin-local-notifications) for my app to have local notifications however it is not working when I have tested it.
I followed this tutorial https://devdactic.com/local-notifications-ionic/
I have tested the app on Ionic View on both android and iOS. I press the buttons but nothing shows up.
I have tried switching $cordovaLocalNotification with cordova.plugins.notification.local. when trying to use the functions in the plugin but that didn't work.
For what it's worth, the plugin does not show up in the package.json file but it does show up when I run the 'cordova plugins' command.
EDIT 1: The following is an image taken from my iPhone after I clicked Add notification
In my $ionicPlatform.ready(function(){...}), I have the following code
if(window.cordova && window.cordova.plugins.notification) {
alert('This alert doesn't fire');
}
The alert doesn't appear which means window.cordova.plugins.notification is unavailable just like the picture indicates
EDIT 2: On the ionic forums it was suggested that the plugin is not working on the Ionic View app as it is not one of the supported plugins. Please refer to: https://forum.ionicframework.com/t/katzers-local-notification-plugin/86748
However it does work when running/testing on a device(android) instead of the Ionic View app.
Add --save at the end of your command, something like:
cordova plugin add de.appplant.cordova.plugin.local-notification --save
It will add it to your config file.
Edit: Maybe you have error while using it. See error log by running the app with following command:
ionic run android -l -c
Finally running in the real device solved the issue.