Facebook Module dialog error picture is not formatted properly - android

How do you include a picture in Titanium's Facebook Module dialog? In Titanium's example, the picture property in the dialog is a link of a picture from a website:
var data =
{
link : "http://www.appcelerator.com",
name : "Appcelerator Titanium Mobile",
message : "Checkout this cool open source project for creating mobile apps",
caption : "Appcelerator Titanium Mobile",
picture : "http://developer.appcelerator.com/assets/img/DEV_titmobile_image.png",
description : "You've got the ideas, now you've got the power. Titanium translates " +
"your hard won web skills into native applications..."
};
fb.dialog("feed", data, function(e)
{
if(e.success && e.result)
{
alert("Success! New Post ID: " + e.result);
}
else
{
if(e.error)
{
alert(e.error);
}
else
{
alert("User canceled dialog.");
}
}
});
But what if you want to use a picture that's local and NOT via a link of a website like this?
var data =
{
link: "http://play.google.com/",
name: "Android app's name",
picture: "file:///data/data/com.appid/app_appdata/directory/name-of-image.jpg"
};
I get the picture property formatting error if I use the code above. See this image for visual reference: http://postimg.org/image/wjefdlalb/
I've tried using the FileSystem like this:
function getFile()
{
var imageFileToPost;
var imageFile = Ti.Filesystem.getFile("file:///data/data/com.appid/app_appdata/directory/name-of-image.jpg");
if (imageFile.exists())
{
console.log("exists");
imageFileToPost = imageFile.read();
}
return imageFileToPost;
}
var data =
{
link: "http://play.google.com/",
name: "Android app's name",
picture: getFile()
};
And the post is successful, there are no errors BUT the picture was NOT published on Facebook.
Note: I would use the graph but I need to use permissions like 'publish_actions' which means I have to to have Facebook review the app but they don't like prefill messages even when the user can edit message anyways. So is this really just a formatting issue with Facebook Module's dialog or it only takes URLs of a picture? If it's a formatting issue, can anyone tell me how to format this correctly because I really need to use the picture that's local and not from a website?

The answer is maybe a bit late, but I had the same issue recently.
It does not seem to be possible with the current version of the Facebook module to create a dialog to share local images.
Because I also needed this functionality for one of my apps, I forked the module (https://github.com/dthulke/ti.facebook) and added a method presentPhotoShareDialog which takes an image blob as argument. Unfortunately it only works if the native Facebook app is installed.
Example:
if (fb.getCanPresentShareDialog()) {
fb.presentPhotoShareDialog({
imageBlob : view.toImage()
});
}

Related

Android Creative SnapKit: Photo with attachment Url pop-up opens twice

I am trying to share Image on SnapChat with attached URL generated from Branch IO. For that I have used Creative SnapKit.
When I clicked on the attached link, it gives me two pop-ups.
First pop-up redirects me to Playstore
The second pop-up redirects me to the installed app.
Ideally, if an app is installed then it should only give a single pop-up which redirects to the App.
I am using the following version:
implementation([ 'com.snapchat.kit.sdk:creative:1.6.3', 'com.snapchat.kit.sdk:core:1.6.3' ])
Implementation:
snapCreativeKitApi = SnapCreative.getApi(getActivity());
snapMediaFactory = SnapCreative.getMediaFactory(getActivity());
SnapPhotoFile photoFile;
try {
photoFile = snapMediaFactory.getSnapPhotoFromFile(fileName);
} catch (SnapMediaSizeException e) {
e.printStackTrace();
return;
}
SnapPhotoContent snapPhotoContent = new SnapPhotoContent(photoFile);
snapPhotoContent.setAttachmentUrl(urlToShare);
finish();
snapCreativeKitApi.send(snapPhotoContent);
AndroidManifest.xml
<meta-data android:name="com.snapchat.kit.sdk.clientId" android:value="ClientID" />
We are using same keys for iOS and Android. For iOS, it's working as expected.
Please let me know if I am doing anything wrong here.
Here is the video link for the issue I am facing:
https://www.dropbox.com/s/ivpshfs9o15kivr/20-08-20-10-32-07.mp4?dl=0
Finally, I found the solution & it was because of Branch IO configuration:
I have changed the configuration > DeepView Manager > Branch Default Bridge Template.
I put Canonical Identifier and Canonical URL as mentioned in the documentation.
For more information, read below Branch IO documents:
https://help.branch.io/using-branch/docs/deepviews
https://blog.branch.io/branch-concepts-the-branch-universal-object/

How to take screenshot and share in mobile using phonegap

I'm trying to take screenshot of current page and share via facebook, whats app, instagram, twitter etc., using phonegap. But was unable to do that properly.
I tried out this code but it doesn't work. Can anyone help me to solve this?
function report() {
let region = document.querySelector("body"); // whole screen
html2canvas(region, {
onrendered: function(canvas) {
let pngUrl = canvas.toDataURL();
let img = document.querySelector(".screen");
img.src = pngUrl; // pngUrl contains screenshot graphics data in url form
window.plugins.socialsharing.share(img.src);
// here you can allow user to set bug-region
// and send it with 'pngUrl' to server
},
});
}

React Native sharing base64 image is not working

I am developing on android. My react-native version is 0.42. I'm using react-native-share package for sharing screen view. The data I want to share is being converted to base64.
...
const uri = "data:image/jpeg;base64,...";
Share.open({
title: "Title",
message: "Message",
url: uri,
subject: "Mail subject"
})
...
This process was working properly on whatsapp, facebook and email before.
However, now, when I tried on whatsapp the response is 'Sharing failed. Please try again', on facebook I'm getting an empty text area without sharing options and on email I'm getting the text typed options except for the image.
Do you have any suggestion? Thank you.
I am using react-native-share but using the shareSingle option like this:
Share.shareSingle({
message:'I just added a new outfit to my album.',
url:Constants.image64, //base64 image
social: "whatsapp"
});
It works great on both the platforms. You can try it if it suffice your needs.

Cordova - Continously taking and uploading pictures

I'm doing a bit of feasability R&D on a project I've been thinking about, the problem is that I'm unfamiliar with the limitations of the Camera API or the OS itself.
I want to write a cordova app which when opened (and authorized), will take a picture every nth second and upload it to a FTP site. Consider it something like a CCTV function, where my site will continuously render the latest image to the user.
Some pseudo code:
while (true) {
var img = api.takePicture(args);
uploadImage(img);
thread.sleep(1000);
}
So my question is, can I access the camera and instruct it to take a picture without user intervention (again, after camera access is authorized)?
Examples or direction for any API call to accomplish it would be really appreciated. I saw this article, and the answer looks promising, but the OP has android and I'd to know if it behaves the same on iOS.
On a side note, how do I test my cordova application on my iPhone without buying an app store license? I only want to run it on my own device.
Solved using CameraPictureBackground plugin:
function success(imgurl) { console.log("Imgurl = " + imgurl); //here I added my function to upload the saved pictures //on my internet server using file-tranfer plugin }
function onFail(message) {
alert('Failed because: ' + message); }
function CaptureBCK() {
var options = {
name: "Image", //image suffix
dirName: "CameraPictureBackground", //foldername
orientation: "portrait", //or landscape
type: "back" //or front
};
window.plugins.CameraPictureBackground.takePicture(success, onFail, options); }
<button onclick="CaptureBCK();">Capture Photo</button> <br>
You will find your pictures under CameraPictureBackground directory in your device acrhive. I used also file-transfer plugin in order to directly upload the pictures on my server over the internet.

Uploading or linking to pictures to a Page from the Facebook Android feed dialog

I have an Android app with a requirement to upload a picture from the Android device to a Page that the user has Liked, using the Feed dialog. (The user is not an administrator of the Page.) I have not been able to get this to work in a way that actually displays the picture on the Page's timeline. I am going to describe what I have done, what happens, and what I would like to see; hopefully someone can help me out.
Here is the sequence of events that happens right now:
Within the app, the user connects to Facebook using the Login button provided by the Android SDK.
The user takes a picture using the app which is stored on the local device.
The app uploads the picture to one of the user's Facebook albums.
The app constructs a URL that points to the picture in the user's album.
The app invokes the Feed dialog with these parameters. "pictureUrl" is the URL that was built in step 4; "pageFbId" is the internal Facebook ID of the Page on which the picture should appear.
Bundle params = new Bundle();
params.putString("link", pictureUrl);
params.putString("to", pageFbId);
The user completes the entry in the Feed dialog.
The page's timeline shows the text entered by the user in the Feed dialog and a link to the picture in the user's album.
Is there a way to do this so that Facebook actually shows the picture on the Page's timeline, instead of just a link to the picture?
Thanks!
Example: Setting picture parameter in Facebook Feed dialog via JS SDK.
IOS, Adroid examples to come.
<script>
function feedthis() {
var obj = {
method: 'feed',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'https://developers.facebook.com/images/devsite/developers_og_image.png',
name: 'Facebook Dialogs',
caption: 'Reference Documentation',
description: 'Test via spoof Post',
properties: [
{ text: 'Link Test 1', href: 'http://example.com'},
{ text: 'Link Test 2', href: 'http://example.com?ref=1'},
],
actions: [
{ name: 'via Test App', link: 'http://anotherfeed.com'}
]
};
function callback(response) { // get post id here from response object.}
FB.ui(obj, callback);
}
</script>

Categories

Resources