Facebook plugin: init not called with valid version - phonegap-plugins

I use phonegap build to create debug version for android.
I want to use facebook plugin.
In Config.xml I have
<gap:plugin name="com.phonegap.plugins.facebookconnect" version="0.4.0">
<param name="APP_ID" value="509210995889450" />
<param name="APP_NAME" value="Food share" />
</gap:plugin>
I use the file facebookConnectPlugin.js which is from the official plugin Github for facebook.
calling:
facebookConnectPlugin.login([], success, fail);
I get:
Error: init not called with valid version
Error
at Object. (http://connect.facebook.net/en_US/sdk.js:37:148)
at window.FB.require (http://connect.facebook.net/en_US/sdk.js:15:588)
at window.FB.require (http://connect.facebook.net/en_US/sdk.js:15:550)
at window.FB.require (http://connect.facebook.net/en_US/sdk.js:15:550)
at window.FB.require (http://connect.facebook.net/en_US/sdk.js:15:550)
at window.FB.require (http://connect.facebook.net/en_US/sdk.js:15:550)
at window.FB.require (http://connect.facebook.net/en_US/sdk.js:15:550)
at window.FB.require (http://connect.facebook.net/en_US/sdk.js:15:550)
at window.FB.require (http://connect.facebook.net/en_US/sdk.js:15:550)
at window.FB.require (http://connect.facebook.net/en_US/sdk.js:15:550)

My mistake was that I tried to work with the official Phonegap plugin for facebook.
It seems Phonegap build uses another plugin, which doesn't use javascript facebookConnectPlugin, as is mentioned in their documentation.
So I used
https://github.com/Wizcorp/phonegap-facebook-plugin
And they use https://github.com/phonegap-build/FacebookConnect/tree/962eb0a1c07935ff813e28aa9eaa5581f2e10416
And usage is different. Very confusing. Also makes it difficult if you try first to build on your desktop, and then it doesn't work on Phonegap Build.

Related

Controller Route not found in production environment

The problem: I am currently working on a custom plugin for Shopware 6 with the development template (https://github.com/shopware/development) and testing it on localhost.
The goal is to use my plugin for our online shop which runs on the production environment (https://github.com/shopware/production)
My problem is that my plugin works exactly like I want on localhost, but not anymore if I upload it to our production environment.
Example: I wrote a new API Controller that introduces a new Route, which does basically the same as the SyncController does but with a little extra logic.
* #Route("/api/v{version}/_action/my-extension/sync",
* name="api.action.my-extension.sync",
* methods={"POST"}
* )
The entry in my services.xml:
<service id="MyExtension\Api\Controller\CustomSyncController" public="true">
<argument type="service" id="Shopware\Core\Framework\Api\Sync\SyncService"/>
<argument type="service" id="serializer"/>
<call method="setContainer">
<argument type="service" id="service_container"/>
</call>
</service>
The entry in my routes.xml:
<import resource="../../Api/Controller" type="annotation" />
As I understand it, that should be sufficient to let Shopware 6 know what my Route is and I should be able to send my POST Request to this Route.
Everything works fine on localhost.
My question:
What steps do I have to take to use this plugin on our production environment, because I always get this message on production:
{"errors":[{"code":"0","status":"404","title":"Not Found","detail":"No route found for \u0022POST \/api\/v3\/_action\/my-extension\/sync\u0022"}]}
What I tried to make it work:
just ZIP the folder custom/plugins/MyExtension and upload my plugin to production.
upload my plugin to localhost, run ./psh.phar administration:build, download the folder from localhost, ZIP this folder and upload it to production.
upload my plugin to localhost, run ./psh.phar administration:build and ./psh.phar storefront:build, download the folder from localhost, ZIP this folder and upload it to production.
After uploading my plugin also start the script "build-administration.sh" and "build-storefront.sh" on our production environment.
Currently I am lost, because I can´t understand what steps are necessary to get the same results in the production environment that I get on localhost.
Meybe you try this in your routes.xml.
<import resource="../../Api/Controller/**/*.php" type="annotation" />
Also the routes.xml file must be located in src/Resources/config/routes.xml in your plugin.
Also you didn't mentioned the installation of the plugin, so you also have to install and activate it.

Error in Azure Function App VS 2019 .NET 3.0 - Method not found: 'IFunctionsHostBuilder.get_Services()'

Issue with Azure Functions/EFSQLSERVER .NET CORE 3.0:
To reproduce:
Use Visual Studio 2019 16.2.1
Use Azure Function template to create a project.
Changed Target Framework to .NET Core 3.0
Add Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0"
reference via Nuget Package Manager.
Excecut Function App using F5
Results in an error as showing in the following snippets. Anyone came across this issue?
Azure Functions Core Tools (2.7.1633 Commit hash: 45c7d86a3bbc9ed0a80a8f4199aa7ea80ccfb24e)
Function Runtime Version: 2.0.12673.0
[10/4/2019 6:13:14 PM] Building host: startup suppressed:False, configuration suppressed: False
[10/4/2019 6:13:14 PM] Loading startup extension 'Startup'
[10/4/2019 6:13:14 PM] Loaded extension 'Startup' (1.0.0.0)
[10/4/2019 6:13:14 PM] Loading startup extension 'DurableTask'
[10/4/2019 6:13:14 PM] Loaded extension 'DurableTask' (1.0.0.0)
[10/4/2019 6:13:14 PM] A host error has occurred
[10/4/2019 6:13:14 PM] FunctionApp5: Method not found: 'Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Azure.Functions.Extensions.DependencyInjection.IFunctionsHostBuilder.get_Services()'.
Value cannot be null.
Parameter name: provider
My nuget packages from csproj file.
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="1.8.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
</ItemGroup>
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
[assembly: FunctionsStartup(typeof(FunctionApp5.Startup))]
namespace FunctionApp5
{
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
**var x = builder.Services;**
}
}
}
For now,ASP.NET Core 3.0 not currently available for Azure App Service, check this Microsoft doc.
Azure Functions 3.0, which will be fully compatible with Core 3.0, will be available in October, check here. However it's not released now.
From this issue, you could find Azure Function 2.0 right now does not work with any Microsoft.Extensions.* 3.* packages and cannot share code with .Net Core 3.0 services.
Further more information about Azure Fuction 3.0 check this discussion.
You can now use .net core 3.0 to create azure functions. Update Microsoft.NET.Sdk.Functions to 1.0.30-beta2 and set AzureFunctionsVersion to v3-preview.
Read more about Develop Azure Functions using .NET Core 3.0 here
You can now use DI using IFunctionsHostBuilder
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
[assembly: FunctionsStartup(typeof(BI_Geo.AzureFunctions.Startup))]
namespace BI_Geo.AzureFunctions
{
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services.AddScoped<IProcess, Process>();
}
}
}
This saved my day
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
To add something else to look out for, the following was our issue:
Our functions app referenced a Domain project
Our Domain project referenced "Microsoft.Extensions.Localization version 5.0.1, which in turn referenced a 5.x version of Microsoft.Extensions.DependencyInjection, which was incompatible with our 3.x runtime. Once we downgraded to reference Microsoft.Extensions.Localization version 3.1.10, the Microsoft.Extensions.DependencyInjection reference downgraded with it and everything worked.
Until Azure Functions 3.0 is available as a stable release, the easiest seems to be to downgrade the Microsoft.Extensions.Http package to 2.2.0:
It helped me with the same problem as there seems to be no other workaround in place for now. Even the available beta packages aren't working on a build server.
More details here: Azure functions dependency injection - error when referencing class library (Github).

add http builder as a dependency of Groovy script

I'm trying to write a Groovy script that depends on the HTTPBuilder library. I'm trying to add this as a dependency of my script via the #Grab annotation shown below
#Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1')
import groovyx.net.http.HTTPBuilder
// rest of script omitted
But when I run this script I get the error:
java.lang.RuntimeException: Error grabbing Grapes -- [download failed: commons-lang#commons-lang;2.4!commons-lang.jar]
I've tested using #Grab to add other dependencies to my script, and the same problem does not occur, why can't I add HTTPBuilder?
Grape may be configured to only look in your local Maven repo for dependencies. To instruct it to also check online repositories, create a config. file ~/.groovy/grapeConfig.xml and add something like the following to it
<ivysettings>
<settings defaultResolver="downloadGrapes"/>
<resolvers>
<chain name="downloadGrapes">
<filesystem name="cachedGrapes">
<ivy pattern="${user.home}/.groovy/grapes/[organisation]/[module]/ivy-[revision].xml"/>
<artifact pattern="${user.home}/.groovy/grapes/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/>
</filesystem>
<!-- todo add 'endorsed groovy extensions' resolver here -->
<ibiblio name="codehaus" root="http://repository.codehaus.org/" m2compatible="true"/>
<ibiblio name="ibiblio" m2compatible="true"/>
<ibiblio name="java.net2" root="http://download.java.net/maven/2/" m2compatible="true"/>
</chain>
</resolvers>
</ivysettings>

VSIX with Project Templates and NuGet Packages

I have been following this post about how to build a VSIX project that will add some custom MVC project types:
http://www.asp.net/mvc/tutorials/mvc-4/custom-mvc-templates
I also want to include some additional Nuget packages, so I was following this page from Nuget, but it seems to be for VS2010 and I'm working in 2012.
I have the project building, and everything works peachy on my machine. The install works, the new project type appears, and when I create a new project of this type, everything works perfectly.
However, when I send the installer to a coworker, things break. The installer works, they see the new project type, but when creating the project he gets error messages about not being able to install any of the packages in the extension node. I've confirmed the Product Id of the extension is correct (I intentionally malformed it in the .vstemplate file during testing and it gave an entirely different error). I've added the packages to the extension manifest, but it doesn't seem to make a difference. I've also confirmed the .nupkg files get deployed to %ProgramFiles(x86)%\Microsoft Visual Studio 11.0\Common7\IDE\Extensions.
Any suggestions on what to do?
Custom Project's .vstemplate section
<WizardExtension>
<Assembly>NuGet.VisualStudio.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
<FullClassName>NuGet.VisualStudio.TemplateWizard</FullClassName>
</WizardExtension>
<WizardData>
<packages repository="registry" keyName="AspNetMvc4VS11" isPreunzipped="true">
<package id="EntityFramework" version="5.0.0" skipAssemblyReferences="true" />
<package id="jQuery" version="1.8.2" />
<!-- snip -->
</packages>
<packages repository="extension" repositoryId="SampleExtensionId">
<package id="Unity" version="3.0.1304.0" targetFramework="net45" />
<package id="Unity.WebAPI" version="0.10" targetFramework="net45" />
<!-- snip -->
</packages>
</WizardData>
source.extension.vsixmanifest Asset tags
<Assets>
<Asset d:VsixSubPath="ProjectTemplates\CustomMVCTemplate" etc/>
<Asset Type="Unity.3.0.1304.0" Path="Packages\Unity.3.0.1304.0.nupkg" />
<Asset Type="Unity.WebAPI.0.10" Path="Packages\Unity.WebAPI.0.10.nupkg" />
<!-- snip -->
</Assets>
File Structure
Extension Project
Packages
NugetPackage 1
NugetPackage 2
etc
ProjectTemplates
CustomMVCTemplate
<custom project files>
source.extension.vsixmanifest
I've made a step by step video on how to make a VSIX that auto downloads nuget packages.
http://www.youtube.com/watch?v=_ZvsFz41H-E
Since there are many steps and I never wrote them down, I won't type them here. I've definitely tested my VSIX package on other people's machine and it worked so hopefully this will work for you.
To download latest versions of NuGet packages plus all their dependencies add a following class to your vsix:
public class MyProjectWizard : IWizard
{
IEnumerable<string> _packages;
public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
{
if (customParams.Length > 0) {
var vstemplate = XDocument.Load((string)customParams[0]);
_packages = vstemplate.Root
.ElementsNoNamespace("WizardData")
.ElementsNoNamespace("packages")
.ElementsNoNamespace("package")
.Select(e => e.Attribute("id").Value)
.ToList();
}
}
public void ProjectFinishedGenerating(Project project)
{
var componentModel = (IComponentModel)Package.GetGlobalService(typeof(SComponentModel));
var _installer = componentModel.GetService<IVsPackageInstaller2>();
foreach (var package in _packages) {
_installer.InstallLatestPackage(null, project, package, false, false);
}
}
}
And then use following in vstemplate:
<WizardExtension>
<Assembly>MyProjectWizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=22c2a1a5fa7b6905</Assembly>
<FullClassName>MyProjectWizard.MyProjectWizard</FullClassName>
</WizardExtension>
Check out this link http://samritchie.net/2012/09/17/nuget-packages-in-vs2012-templates/ which helped me. However, I'm still running into the issue where all my references' paths are empty.
Note especially the following comment from the article linked above:
I spent a considerable period of time attempting to work out what the v2 equivalent of CustomExtension was, but to cut a long story short, you don’t need to make any changes to the .vsixmanifest — it’s enough to include all of the packages in the VSIX under a ‘Packages’ directory.

Disable automatic download for Groovy grapes

A sample script ss.groovy:
#Grab(group='org.codehaus.groovy.modules.http-builder',
module='http-builder',
version='0.5.0')
import groovyx.net.http.HTTPBuilder
println('done')
for some reason takes ~25 seconds to load when run with
groovy ss.groovy
and ~5 seconds when run with
groovy -Dgroovy.grape.autoDownload=false ss.groovy
as per this StackOverflow explanation. I tried doing manual initialization with
Grape.enableAutoDownload = false
Grape.grab(group:'org.codehaus.groovy.modules.http-builder',
module:'http-builder',
version:'0.5.0')
import groovyx.net.http.HTTPBuilder
println('done')
but this fails on import with:
/tmp/ss.groovy: 3: unable to resolve class groovyx.net.http.HTTPBuilder
# line 3, column 1.
import groovyx.net.http.HTTPBuilder
^
Is there a contained way to either:
Make it not download the artifacts automatically (preferred, as it allows for solving other issues, e.g. external site down while an artifact already exists in the local cache)
Make it startup faster in any other way
By contained I mean that all additional instructions should be either within script or, if no such one exists, an acceptable default (e.g. don't check the cached artifacts for updates - I would still, however, like to have automatic downloads globally) to be put in some of groovy config files (e.g. ~/.groovy/grapeConfig.xml or similar).
Update: The issue has been fixed, #GrabConfig(autoDownload=false) will be available in Groovy 2.2
Why not install a repository manager locally?
http://nexus.sonatype.org/
I use Nexus to proxy and cache all my 3rd party repositories. Groovy is the configured to retrieve from either it's local cache or Nexus:
<ivysettings>
<settings defaultResolver="downloadGrapes"/>
<resolvers>
<chain name="downloadGrapes">
<filesystem name="cachedGrapes">
<ivy pattern="${user.home}/.groovy/grapes/[organisation]/[module]/ivy-[revision].xml"/>
<artifact pattern="${user.home}/.groovy/grapes/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/>
</filesystem>
<!-- Local Nexus Repository -->
<ibiblio name="nexus" root="http://localhost:8081/nexus/repositories/public" m2compatible="true"/>
</chain>
</resolvers>
</ivysettings>
This doesn't seem to be possible with the current (Groovy 1.8.1) implementation. I created an improvement ticket: http://jira.codehaus.org/browse/GROOVY-4943.

Resources