Cordova WKWebView white screen - iphone

I'm trying to get a simple JavaScript application running inside of Cordova on my iPhone. The project works perfectly fine inside the simulator but displays a strange screen when running it on my phone.
Here's my config.xml file:
<widget
id="com.landonschropp.tictactoe"
version="1.0.0"
xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Tic-Tac-Toe</name>
<description>An awesome little tic-tac-toe game.</description>
<author email="schroppl#gmail.com" href="https://landonschropp.com">Landon Schropp</author>
<content src="http://localhost:8080" />
<access origin="*" />
<allow-navigation href="http://localhost:8080/*" />
<feature name="CDVWKWebViewEngine">
<param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
<plugin name="cordova-plugin-statusbar" spec="^2.2.3" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.2" />
<plugin
name="cordova-plugin-wkwebview-engine"
spec="git+https://github.com/driftyco/cordova-plugin-wkwebview-engine.git" />
<engine name="ios" spec="^4.4.0" />
</widget>
and my package.json file:
{
"name": "tic_tac_toe",
"description": "A simple tic-tac-toe game",
"dependencies": {
"axios": "^0.16.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"cheerio": "^0.22.0",
"cordova": "^7.0.0",
"cordova-ios": "^4.4.0",
"cordova-plugin-statusbar": "^2.2.3",
"cordova-plugin-whitelist": "^1.3.2",
"cordova-plugin-wkwebview-engine": "git+https://github.com/driftyco/cordova-plugin-wkwebview-engine.git",
"gulp": "^3.9.1",
"gulp-connect": "^5.0.0",
"gulp-file-cache": "^0.0.1",
"gulp-sass": "^3.1.0",
"gulp-sass-glob": "^1.0.8",
"gulp-transform": "^1.1.0",
"gulp-util": "^3.0.8",
"gulp-watch": "^4.3.11",
"lodash": "^4.17.4",
"phaser": "^2.6.2",
"rollup": "^0.41.6",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-json": "^2.1.1",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-stream": "^1.19.0",
"run-sequence": "^1.2.2",
"vinyl-source-stream": "^1.1.0"
},
"devDependencies": {
"babel-register": "^6.24.1",
"chai": "^3.5.0",
"del": "^2.2.2",
"eslint": "^3.19.0",
"mocha": "^3.2.0"
},
"cordova": {
"platforms": [
"ios"
],
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-wkwebview-engine": {},
"cordova-plugin-statusbar": {}
}
}
}
To build and run the app, I do the following:
yarn install
cordova platform add ios
cordova run ios
Currently, when running the app on my phone I see the following screen:

As dymv mentioned, the issue is most likely that your app cannot reach localhost, since "localhost" in this context was your development computer, not the iPhone. Can you deploy it to a hosted server solution and retest?
The WKWebView plugin is not a local server, but rather an enhanced WebView component (a WebView is basically an embedded browser in your app that runs your HTML, CSS, JavaScript code). The core benefit is that it processes JavaScript faster (much faster!) so your app will perform better.

Related

Ionic v2 Download and display Image

I am trying to develop an application where I have to download and display an image from a website. THis is the code snippet which I have used:-
LoadImage(){
const transfer = new Transfer();
var url = "http://demo.observerjobs.lk/storage/public/uploads/vacancies/"+this.hash+"/"+this.attachment;
var uri = encodeURI(url);
var filepath = cordova.file.cacheDirectory+ '/' + this.vacancy.attachment;//("/"+this.vacancy.attachment);
transfer.download(uri, filepath, true ).then((entry) => {
console.log('download complete: ' + entry );
this.image = "<ion-img src= '"+ entry.toURL() + "'/>";
console.log(this.image);
}).catch(error => {
console.log(JSON.stringify(error));
});
}
I create the img tag in the following format:-
"<ion-img src= 'file:///data/user/0/package_name/cache/suo-01-29-012588-12x3-kbd.jpg'/>"
However, I am unable to retrieve this file to be displayed. What Have I done wrong, and what can I do to remedy this?
Edit:- Here is the config.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="OBSCURED FOR IDENTITY" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>OBSCURED</name>
<description>An awesome Ionic/Cordova app.</description>
<author email="hi#ionicframework" href="http://ionicframework.com/">Ionic Framework Team</author>
<content src="index.html"/>
<access origin="*"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<allow-intent href="tel:*"/>
<allow-intent href="sms:*"/>
<allow-intent href="mailto:*"/>
<allow-intent href="geo:*"/>
<platform name="android">
<allow-intent href="market:*"/>
<icon src="resources\android\icon\drawable-ldpi-icon.png" density="ldpi"/>
<icon src="resources\android\icon\drawable-mdpi-icon.png" density="mdpi"/>
<icon src="resources\android\icon\drawable-hdpi-icon.png" density="hdpi"/>
<icon src="resources\android\icon\drawable-xhdpi-icon.png" density="xhdpi"/>
<icon src="resources\android\icon\drawable-xxhdpi-icon.png" density="xxhdpi"/>
<icon src="resources\android\icon\drawable-xxxhdpi-icon.png" density="xxxhdpi"/>
<splash src="resources\android\splash\drawable-land-ldpi-screen.png" density="land-ldpi"/>
<splash src="resources\android\splash\drawable-land-mdpi-screen.png" density="land-mdpi"/>
<splash src="resources\android\splash\drawable-land-hdpi-screen.png" density="land-hdpi"/>
<splash src="resources\android\splash\drawable-port-ldpi-screen.png" density="port-ldpi"/>
<splash src="resources\android\splash\drawable-port-mdpi-screen.png" density="port-mdpi"/>
<splash src="resources\android\splash\drawable-port-hdpi-screen.png" density="port-hdpi"/>
</platform>
<platform name="ios">
<allow-intent href="itms:*"/>
<allow-intent href="itms-apps:*"/>
</platform>
<platform name="windows">
<preference name="windows-target-version" value="10.0"/>
</platform>
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="android-minSdkVersion" value="16"/>
<preference name="BackupWebStorage" value="none"/>
<preference name="SplashMaintainAspectRatio" value="true"/>
<preference name="FadeSplashScreenDuration" value="300"/>
<preference name="SplashScreen" value="screen"/>
<preference name="SplashScreenDelay" value="3000"/>
<feature name="StatusBar">
<param name="ios-package" onload="true" value="CDVStatusBar"/>
</feature>
<plugin name="ionic-plugin-keyboard" spec="~2.2.1"/>
<plugin name="cordova-plugin-whitelist" spec="1.3.1"/>
<plugin name="cordova-plugin-console" spec="1.0.5"/>
<plugin name="cordova-plugin-statusbar" spec="2.2.1"/>
<plugin name="cordova-plugin-device" spec="1.1.4"/>
<plugin name="cordova-plugin-splashscreen" spec="~4.0.1"/>
<icon src="resources\android\icon\drawable-xhdpi-icon.png"/>
<allow-navigation href="http://192.168.1.3:8100"/>
<allow-navigation href="http://192.168.1.3:8101"/>
<allow-navigation href="http://192.168.1.2:8100"/>
<allow-navigation href="http://192.168.8.105:8100"/>
</widget>
Here is the http file of the relevant page:-
<!--
Generated template for the Vacancy page.
See http://ionicframework.com/docs/v2/components/#navigation for more info on
Ionic pages and navigation.
-->
<ion-header>
<ion-navbar>
<ion-title>Vacancy</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-list no-lines *ngIf="vacancy">
<ion-item >Contract Type : {{vacancy.value}}</ion-item>
<ion-item >Company : {{item.company_name}}</ion-item>
<ion-item >Deadline : {{ deadlinetime }}</ion-item>
<ion-item >Job ID : #JD{{ item.id }}</ion-item>
</ion-list>
<h2 *ngIf="vacancy" orientation="center">{{item.job_title}}</h2>
<div *ngIf="image" [innerHtml]="image"></div>
</ion-content>
I would try:
Component:
imageSrc:string//class variable
LoadImage(){
const transfer = new Transfer();
var url = "http://demo.observerjobs.lk/storage/public/uploads/vacancies/"+this.hash+"/"+this.attachment;
var uri = encodeURI(url);
var filepath = cordova.file.cacheDirectory+ '/' + this.vacancy.attachment;//("/"+this.vacancy.attachment);
transfer.download(uri, filepath, true ).then((entry) => {
console.log('download complete: ' + entry );
this.imageSrc = entry.toUrl();
console.log(this.imageSrc);
}).catch(error => {
console.log(JSON.stringify(error));
});
}
HTML:
<img *ngIf="imageSrc" [src]="imageSrc"></img>

Is this correct Open Office XML?

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<?mso-application progid="Word.Document"?>
<pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage">
<pkg:part pkg:name="/_rels/.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:padding="512">
<pkg:xmlData>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml" />
</Relationships>
</pkg:xmlData>
</pkg:part>
<pkg:part pkg:name="/word/_rels/document.xml.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:padding="256">
<pkg:xmlData>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="media/image1.png" />
</Relationships>
</pkg:xmlData>
</pkg:part>
<pkg:part pkg:name="/word/document.xml" pkg:contentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml">
<pkg:xmlData>
<w:document mc:Ignorable="w14 w15 wp14" xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape">
<w:body>
<w:p w:rsidR="00AE3E50" w:rsidRDefault="00DE2072">
<w:r>
<w:drawing>
<wp:inline distT="0" distB="0" distL="0" distR="0">
<wp:extent cx="2194560" cy="1463040" />
<wp:docPr id="1" name="My Video" />
<wp:cNvGraphicFramePr>
<a:graphicFrameLocks noChangeAspect="1" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" />
</wp:cNvGraphicFramePr>
<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:nvPicPr>
<pic:cNvPr id="1" name="" />
<pic:cNvPicPr />
</pic:nvPicPr>
<pic:blipFill>
<a:blip r:embed="rId2">
<a:extLst>
<a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
<a14:useLocalDpi val="0" xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" />
</a:ext>
<a:ext uri="{C809E66F-F1BF-436E-b5F7-EEA9579F0CBA}">
<wp15:webVideoPr embeddedHtml="<iframe width="800" height="600" src="http://www.youtube.com/embed/qk51u8-4uo4" frameborder="0" allowfullscreen></iframe>" w="800" h="600" xmlns:wp15="http://schemas.microsoft.com/office/word/2012/wordprocessingDrawing" />
</a:ext>
</a:extLst>
</a:blip>
<a:stretch>
<a:fillRect />
</a:stretch>
</pic:blipFill>
<pic:spPr>
<a:xfrm>
<a:off x="0" y="0" />
<a:ext cx="2194560" cy="1463040" />
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst />
</a:prstGeom>
</pic:spPr>
</pic:pic>
</a:graphicData>
</a:graphic>
</wp:inline>
</w:drawing>
</w:r>
</w:p>
</w:body>
</w:document>
</pkg:xmlData>
</pkg:part>
<pkg:part pkg:name="/word/media/image1.png" pkg:contentType="image/png" pkg:compression="store">
<pkg:binaryData>
iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAHN6w8ZAAAAAXNSR0IArs4c6QAAAARnQU1BAACx
jwv8YQUAAAAGUExURQAAAAAAAKVnuc8AAAACdFJOU/8A5bcwSgAAAAlwSFlzAAAOxAAADsQBlSsO
GwAAAAxJREFUGFdjYBgYAAAAeAABoRR6NAAAAABJRU5ErkJggg==
</pkg:binaryData>
</pkg:part>
</pkg:package>
I'm not sure whether above one is correct or not but it keeps giving me error "Invalid format" while adding to MS word using programming".
The error is
Error Message: The format of the specified data object is invalid.
Error Code: 2006
Here is click event for the buttonw which is inserting code...
Office.context.document.setSelectedDataAsync
(
xmlCode,
{ coercionType: "ooxml" },
function (result)
{
console.log("test");
}
);
variable xmlCode is consists of ooxml code as string data.
It's solved now...
The mistake that I was doing is, I have placed the ooxml code inside a <textarea> html element. So while it was being rendered inside browser, the html encoded iframe code was converted into HTML tags which was causing issue. I updated my code, removed ooxml code from <textarea> and placed it directly as string to variable and the problem was solved.
Now, I'm able to embed video using office.js
I'm not entirely sure that the OOXML data should be a string.
Writing data from apps to Office documents suggests that you should be using a CustomXmlNode object:
In the event that you cannot insert content through any of the above methods, and if you are in Word 2013, you can directly alter the structure of the document by inserting OOXML nodes. This gets complicated fast—refer to the Apps for Office CustomXmlNode APIs for more information.
(I especially love "this gets complicated fast"...sure makes me excited to use that API!)

Rest Api Magento Request does not match any route

This is my xml file on Magento
<config>
<api2>
<resource_groups>
<extendrestapi translate="title" module="api2">
<title>Extended Rest API</title>
<sort_order>10</sort_order>
</extendrestapi>
</resource_groups>
<resources>
<extendrestapicategory translate="title" module="api2">
<group>extendrestapi</group>
<model>extendrestapi/api2_category</model>
<title>Categories</title>
<sort_order>10</sort_order>
<privileges>
<admin>
<retrieve>1</retrieve>
</admin>
<guest>
<retrieve>1</retrieve>
</guest>
</privileges>
<attributes>
<entity_id>Category ID</entity_id>
<name>Name</name>
<parent_id>Category Parent ID</parent_id>
<is_active>Active</is_active>
<level>Level</level>
<position>Position</position>
<children>Children Ids</children>
<url_key>URL key</url_key>
<store_id>Store ID</store_id>
</attributes>
<routes>
<route_entity>
<route>/ikom/categories/:id</route>
<action_type>collection</action_type>
</route_entity>
<route_collection>
<route>/ikom/categories</route>
<action_type>collection</action_type>
</route_collection>
</routes>
<versions>1</versions>
</extendrestapicategory>
<extendrestapiproductattribute translate="title" module="api2">
<group>extendrestapi</group>
<model>extendrestapi/api2_productattribute</model>
<title>Product Attributes</title>
<sort_order>10</sort_order>
<privileges>
<admin>
<retrieve>1</retrieve>
</admin>
<guest>
<retrieve>1</retrieve>
</guest>
</privileges>
<attributes>
<id>Name</id>
<options>Options value/label</options>
</attributes>
<routes>
<route_entity>
<route>/testapi/:id</route>
<action_type>collection</action_type>
</route_entity>
<route_collection>
<route>/testapi</route>
<action_type>collection</action_type>
</route_collection>
</routes>
<versions>1</versions>
</extendrestapiproductattribute>
</resources>
</api2>
</config>
I do not know why I run this url http://localhost/magento_4/api/rest/ikom/testapi/1, this have response {"messages":{"error":[{"code":404,"message":"Request does not match any route."}]}}.
What wrong here ?
The configuration is not yet ready, let's see this http://www.authenticdesign.co.uk/extending-magento-rest-api-v2/#part1

Eclipse 3.5.1 RCP Styled string not updating in package navigator

I have a problem presumably with eclipse 3.5.1. I have a plugin that, besides other things, adds a string decoration to files that have been changed. Everything works fine in eclipse 3.7.1, but on the target application which stands on eclipse 3.5.1 the navigator does not display the styled string correctly.
The code for string decorations is as follows (it also adds the file version, which also does not work on eclipse 3.5.1):
public class CustomLabelProvider extends ResourceExtensionLabelProvider implements
org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider {
#Override
public StyledString getStyledText(Object element) {
StyledString label = new StyledString();
try {
Set modifiedFiles =
CustomContentProvider.getModifiedSegments().get(
((Resource) element).toString().substring(1));
if ((modifiedFiles != null) && (modifiedFiles.size() > 0)) {
label.append(">", StyledString.DECORATIONS_STYLER);
}
label.append(getText(element));
if (element instanceof ExtendedFile) {
Integer fileVersion = ((ExtendedFile) element).getFileVersion();
if (fileVersion != null) {
label.append(" ").append(fileVersion.toString(), StyledString.DECORATIONS_STYLER);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return label;
}
A comparison between both eclipse versions:
Both eclipse 3.5.1 and 3.7.1 implement IStyledLabelProvider. The plugin starts in both eclipse versions, osgi lists it as ACTIVE, and there is some logging that I cut out, that works in both eclipse versions. What could be the reason for this behaviour?
UPDATE: The label provider plugin.xml
<plugin>
<extension
point="org.eclipse.ui.navigator.viewer">
<viewer
viewerId="myApplication.NavigatorView">
</viewer>
<viewerContentBinding viewerId="myApplication.NavigatorView">
<includes>
<contentExtension pattern="NavigatorLabelProvider.NavigatorContent"/>
</includes>
</viewerContentBinding>
</extension>
<extension
point="org.eclipse.ui.navigator.navigatorContent">
<navigatorContent
name="myNavigatorContent"
activeByDefault="true"
contentProvider="labelprovider.CustomContentProvider"
labelProvider="labelprovider.CustomLabelProvider"
id="NavigatorLabelProvider.NavigatorContent">
<enablement>
<or>
<adapt type="org.eclipse.core.resources.IProject" />
<instanceof
value="org.eclipse.core.resources.IResource" />
</or>
</enablement>
<commonSorter
class="org.eclipse.ui.internal.navigator.resources.workbench.ResourceExtensionSorter"
id="org.eclipse.ui.navigator.resources.sorters.defaultSorter">
<parentExpression>
<or>
<instanceof value="org.eclipse.core.resources.IResource" />
</or>
</parentExpression>
</commonSorter>
<dropAssistant
class="org.eclipse.ui.navigator.resources.ResourceDropAdapterAssistant"
id="org.eclipse.ui.navigator.resources.resourceDropAdapter">
<possibleDropTargets>
<or>
<adapt type="org.eclipse.core.resources.IProject"/>
<adapt type="org.eclipse.core.resources.IFolder"/>
<adapt type="org.eclipse.core.resources.IFile"/>
</or>
</possibleDropTargets>
</dropAssistant>
<actionProvider
class="org.eclipse.ui.internal.navigator.resources.actions.EditActionProvider"
id="org.eclipse.ui.navigator.resources.actions.EditActions"/>
<actionProvider
class="org.eclipse.ui.internal.navigator.resources.actions.RefactorActionProvider"
id="org.eclipse.ui.navigator.resources.actions.RefactorActions"/>
<!-- Menu Shortcut Actions for Wizards -->
<commonWizard
type="new"
wizardId="org.eclipse.ui.wizards.new.folder">
<enablement>
<or>
<adapt type="org.eclipse.core.resources.IFile" />
<adapt type="org.eclipse.core.resources.IFolder" />
<adapt type="org.eclipse.core.resources.IProject" />
<adapt type="org.eclipse.core.resources.IWorkspaceRoot" />
</or>
</enablement>
</commonWizard>
<commonWizard
type="new"
wizardId="org.eclipse.ui.wizards.new.file">
<enablement>
<or>
<adapt type="org.eclipse.core.resources.IFile" />
<adapt type="org.eclipse.core.resources.IFolder" />
<adapt type="org.eclipse.core.resources.IProject" />
<adapt type="org.eclipse.core.resources.IWorkspaceRoot" />
</or>
</enablement>
</commonWizard>
</navigatorContent>
</extension>
</plugin>

FacebookConnect plugin with phonegap adobe build not working

I have a Phonegap projct which is being built with adobe build.
I want to integrate FacebookConnect as per this git / tutorial page : https://github.com/phonegap-build/FacebookConnect
This is my adobe build config.xml :
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns= "http://www.w3.org/ns/widgets"
xmlns:gap= "http://phonegap.com/ns/1.0"
id= "com.TomBers.foodidapp"
version = "0.0.1">
<cordova>
<preference name="KeyboardDisplayRequiresUserAction" value="true" />
<preference name="SuppressesIncrementalRendering" value="false" />
<preference name="UIWebViewBounce" value="true" />
<preference name="TopActivityIndicator" value="gray" />
<preference name="EnableLocation" value="false" />
<preference name="EnableViewportScale" value="false" />
<preference name="AutoHideSplashScreen" value="true" />
<preference name="ShowSplashScreenSpinner" value="true" />
<preference name="MediaPlaybackRequiresUserAction" value="false" />
<preference name="AllowInlineMediaPlayback" value="false" />
<preference name="BackupWebStorage" value="cloud" />
<preference name="orientation" value="portrait" />
<preference name="phonegap-version" value="2.5.0" />
<content src="index.html" />
<plugins>
<plugin name="Device" value="CDVDevice" />
<plugin name="Logger" value="CDVLogger" />
<plugin name="Compass" value="CDVLocation" />
<plugin name="Accelerometer" value="CDVAccelerometer" />
<plugin name="Camera" value="CDVCamera" />
<plugin name="NetworkStatus" value="CDVConnection" />
<plugin name="Contacts" value="CDVContacts" />
<plugin name="Debug Console" value="CDVDebugConsole" />
<plugin name="Echo" value="CDVEcho" />
<plugin name="File" value="CDVFile" />
<plugin name="FileTransfer" value="CDVFileTransfer" />
<plugin name="Geolocation" value="CDVLocation" />
<plugin name="Notification" value="CDVNotification" />
<plugin name="Media" value="CDVSound" />
<plugin name="Capture" value="CDVCapture" />
<plugin name="SplashScreen" value="CDVSplashScreen" />
<plugin name="Battery" value="CDVBattery" />
<plugin name="Globalization" value="CDVGlobalization" />
<plugin name="InAppBrowser" value="CDVInAppBrowser" />
<plugin name="com.phonegap.facebook.Connect" value="com.phonegap.facebook.ConnectPlugin" />
<gap:plugin name="FacebookConnect">
<param name="APP_ID" value="133914256793487" />
</gap:plugin>
</plugins>
<access origin="*" />
</cordova>
</widget>
I then added the various javascript scraps and buttons shown in the Simple example : https://github.com/phonegap-build/FacebookConnect/tree/master/example/Simple including :
document.addEventListener('deviceready', function() {
try {
alert('Device is ready! Make sure you set your app_id below this alert.');
FB.init({ appId: "133914256793487", nativeInterface: CDV.FB, useCachedDialogs: false });
document.getElementById('data').innerHTML = "";
} catch (e) {
alert(e);
}
}, false);
With my updated appid. When my app loads - i get the alert saying device is ready!
Then I get 2 more alerts, one saying : plugin fail on init.
Then one saying : plugin fail on auth.status.
I have added my android debug keystore hash to the app on facebook + my developer settings.
I am not sure how to debug from here.
Cheers,
Andy
I would suggest you use the inappbrowser plugin to do this instead... example shown below.
Fill in the xxx below with your relevant info
var my_client_id = "xxxxxx", // YOUR APP ID
my_secret = "xxxxxxxxx", // YOUR APP SECRET
my_redirect_uri = "https://www.facebook.com/connect/login_success.html", // LEAVE THIS
my_type ="user_agent", my_display = "touch"; // LEAVE THIS
var facebook_token = "fbToken"; // OUR TOKEN KEEPER
var ref; //IN APP BROWSER REFERENCE
// FACEBOOK
var Facebook = {
init:function(){
// Begin Authorization
var authorize_url = "https://www.facebook.com/dialog/oauth?";
authorize_url += "client_id=" + my_client_id;
authorize_url += "&redirect_uri=" + my_redirect_uri;
authorize_url += "&display=" + my_display;
authorize_url += "&scope=publish_stream";
//CALL IN APP BROWSER WITH THE LINK
ref = window.open(authorize_url, '_blank', 'location=no');
ref.addEventListener('loadstart', function(event){
Facebook.facebookLocChanged(event.url);
});
},
facebookLocChanged:function(loc){
if (loc.indexOf("code=") >= 1 ) {
//CLOSE INAPPBROWSER AND NAVIGATE TO INDEX
ref.close();
//THIS IS MEANT TO BE DONE ON SERVER SIDE TO PROTECT CLIENT SECRET
var codeUrl = 'https://graph.facebook.com/oauth/access_token?client_id='+my_client_id+'&client_secret='+my_secret+'&redirect_uri='+my_redirect_uri+'&code='+loc.split("=")[1];
console.log('CODE_URL::' + codeUrl);
$.ajax({
url: codeUrl,
data: {},
type: 'POST',
async: false,
cache: false,
success: function(data, status){
//WE STORE THE TOKEN HERE
localStorage.setItem(facebook_token, data.split('=')[1].split('&')[0]);
},
error: function(){
alert("Unknown error Occured");
}
});
}
}
I would add more functions for logout and posting to a wall etc.
You can find documenatation on the inappbrowser here
After hours and hours of trying I got this to work.
Here's what's wrong with the proposed xml:
Tag cordova is wrong, remove it.
Tag gap:plugin does NOT go inside the plugins tag.
Tag plugin name="com.phonegap.facebook.Connect" is unnecessary and probably wrong.
Then I suggest inspecting the .apk file produced by phonegap build. If things are working as they should the files cdv-plugin-fb-connect.js and facebook-js-sdk.js should be present in assets/www.
By the way those files must not be present in the supplied src.