I am trying to share image particularly in WeChat and WhatsApp by using this plugin : EddyVerbruggen/SocialSharing-PhoneGap-Plugin
window.plugins.socialsharing.shareVia('whatsapp','msg',null,
'images/hello.png' , null /* url */, function(e) {
console.log('share' +e)
}, function(errormsg){
alert(errormsg)
})
window.plugins.socialsharing.shareVia('com.tencent.mm','msg',null,
'images/hello.png' , null /* url */, function(e) {
console.log('share' +e)
}, function(errormsg){
alert(errormsg)
})
My app gets crashed in ios but in android it works fine.
by using another method shareViaWhatsapp:
window.plugins.socialsharing.shareViaWhatsApp('Message via WhatsApp'
,'images/hello.png', function() {
console.log('share ok')
}, function(errormsg){
alert(errormsg)
})
This method working in android but in ios its showing all the apps to share when i share image, If i share only message its working properly in ios. Please guide me.
Sharing to whatsApp with shareViaWhatsApp is not working on iOs also in my case I can confirm.
Only way I was able to share picture was using share sheet with the plugin you mentioned.
So its something like:
this.socialSharing.share(null, null, this.screen, null).then(() => {
console.log(' succ share test')
this.shareWhatsApp()
}).catch((e) => {
console.log(' err share test')
this.shareWhatsApp()
});
Related
I'd like for users to be able to share a link (e.g. app.com/SKFLA - this is primarily because deep links on their own aren't clickable) via Facebook etc. When clicked, this redirects to a deep link app://SKFLA. If the app is installed, this opens the app - this is all working fine so far. But if the app isn't installed, I'd like to open the app store on the relevant page. Is this achievable? Thanks!
You need UNIVERSAL LINKS
Please check
IOS https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html
Android
https://developer.android.com/training/app-links/
It might also require some extra server-side setup.
Not sure about native behavior.
We used third-party service like https://branch.io/deepviews/.
There is a bunch of similar services.
If someone is still stuck in this issue and needs easiest solution, you will love node-deeplink
1.) If app is installed: Calling an app through deep linking will always call componentDidMount of root component. So you can attach a listener there. Like:
Linking.getInitialURL()
.then(url => {
if (url) {
this.handleOpenURL({ url });
}
})
.catch(console.error);
Linking.addEventListener('url', this.handleOpenURL);
handleOpenURL(event) {
if (event) {
console.log('event = ', event);
const url = event.url;
const route = url.replace(/.*?:\/\//g, '');
console.log('route = ', route);
if(route.match(/\/([^\/]+)\/?$/)) {
const id = route.match(/\/([^\/]+)\/?$/)[1];
const routeName = route.split('/')[0];
if (routeName === 'privatealbum') {
Actions.privateAlbum({ albumId: id });
}
}
}
}
2.) If app is not installed: Just set up a route in your server and node-deeplink package will handle the bridging between web browser to app store when a app is not installed in your mobile.
By this, both the cases will be handled without any struggle
I have a button and I want to open a facebook page in the facebook app. I can use this solution to open the link in a browser but I'm looking for a better solution that opens faecbook app and my desire page. Is this generally possible? How?
This may not be possible on Android but to do so you follow essentially the same instructions for linking, you just need to swap out http with fb (or the appropriate app id). This SO answer has a bit more information on what may or may not be possible.
Assuming it is possible, to open the facebook app to a profile it would look something like this
const pageId = 'abc123'
Linking.openURL(`fb://profile/${pageId}`)
.catch(err => console.error('An error occurred', err));
Notice that rather than using http I'm using fb
Same as solution of #Spencer answered, but using page instead profile to open fanpage.
<Button
title="Go to Facebook page"
onPress={() => {
const FANPAGE_ID = 'xxxxxxxxxxxxxxxxx'
const FANPAGE_URL_FOR_APP = `fb://page/${FANPAGE_ID}`
const FANPAGE_URL_FOR_BROWSER = `https://fb.com/${FANPAGE_ID}`
Linking.canOpenURL(FANPAGE_URL_FOR_APP)
.then((supported) => {
if (!supported) {
Linking.openURL(FANPAGE_URL_FOR_BROWSER)
} else {
Linking.openURL(FANPAGE_URL_FOR_APP)
})
.catch(err => console.error('An error occurred', err))
}}
/>
Note: You MUST use fanpage ID, not fanpage slug name. If you don't know how to get id, just open your fanpage in browser, view source and find page_id param.
A mix of answers from #Spencer and #Thành worked for me on iOS.
So I settled for just attempting to open the Facebook app link, and then if that fails I fall back to the web browser link, like so:
import { Linking } from "react-native";
const openFacebookLink = facebookId => {
const FANPAGE_URL_FOR_APP = `fb://profile/${facebookId}`;
const FANPAGE_URL_FOR_BROWSER = `https://fb.com/${facebookId}`;
Linking.canOpenURL(FANPAGE_URL_FOR_APP)
.then(appSupported => {
if (appSupported) {
console.log(`Can handle native url: ${FANPAGE_URL_FOR_APP}`);
return Linking.openURL(FANPAGE_URL_FOR_APP);
} else {
console.log(
`Can't handle native url ${FANPAGE_URL_FOR_APP} defaulting to web URL ${FANPAGE_URL_FOR_BROWSER}`
);
return Linking.canOpenURL(FANPAGE_URL_FOR_BROWSER).then(
webSupported => {
if (webSupported) {
console.log(`Can handle web url: ${FANPAGE_URL_FOR_BROWSER}`);
return Linking.openURL(FANPAGE_URL_FOR_BROWSER);
}
return null;
}
);
}
})
.catch(err => console.error("An error occurred", err));
};
Note: the appSupported variable here will always return false until you've edited/added the LSApplicationQueriesSchemes value in your info.plist file. You'll find this file in the ios/yourappname sub-folder of your project. Here are the lines that I added to mine:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fb</string>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
NB: if you're using Create React Native App and/or Expo then you won't be able to edit this file. I abandoned Expo for this reason.
That works on iOS for me, but Android opens it in the browser every time. I've read that Android handles this stuff completely differently to iOS, so I'm not sure if there's any easy solution there.
How to open other apps (Gmail, Camera) from ReactNative. How can I pass data from current scene to other app?
I found this npm library react-native-app-link which can open other apps. This is based on deep linking, if you have any deep links then this library can help. This doesn't open apps just by giving the android package name or ios app id.
https://github.com/FiberJW/react-native-app-link
you can mange opening other apps using Linking
Code sample for opening the dialer
const urlToOpen = 'tel:1234567890';
Linking.openURL(urlToOpen);
You can refer to the official doc here, it just predefines some applications, which can be opened.
However, if the question is about to open just about any application, I hope there is no solution till now.
react-native-app-link has some redundant config (e.g. appStoreLocale parameter), so I wrote my own realization using their code:
import { Alert, Platform, ToastAndroid } from 'react-native';
const isIos = Platform.OS === 'ios';
const showNotification = (text) => isIos
? Alert.alert(text)
: ToastAndroid.show(text, ToastAndroid.SHORT);
const openApp = ({ url, appStoreId, playMarketId, name }) => {
Linking.openURL(url).catch(err => {
if (err.code === 'EUNSPECIFIED') {
Linking.openURL(
isIos
? `https://apps.apple.com/app/id${appStoreId}`
: `https://play.google.com/store/apps/details?id=${playMarketId}`,
);
} else {
showNotification(`Can't open ${name} app`);
}
});
};
It tries to open the app by the specified link, and if the user doesn't have such one, it opens its page in AppStore or Play Market.
I am using Facebook plugin (http://ngcordova.com/docs/plugins/facebook/
) of Cordova. I am using this plugin with ionic framework. I am all done with installing this plugin on android. I have created an appId and the app is under development. So for the testing I am using test user generated in - https://developers.facebook.com/apps/123456789/roles/test-users/ I want to share a feed on Facebook but I am not able to do that. I am checking getLoginStatus method and on its success I want to post a feed. Here is my code
$scope.getFbLoginStatus = function(){
$cordovaFacebook.getLoginStatus()
.then(function(success) {
alert("Logged In");
$scope.shareFeed = function(){
$cordovaFacebook.showDialog({method: "feed", link:"https://github.com/Wizcorp/phonegap-facebook-plugin/commit/7b4a56f5717a50d3387abe4a2fa6156fe1aea852", caption: "Here is the caption"
})
.then(function(success) {
alert("check whether image shared or not" );
// success
}, function (error) {
alert("image not shared");
// error
});
}
}, function (error) {
alert("Permission denied");
});
}
I have not used facebook SDK as it was not listed in the installation steps.
I want to implement Facebook feed dialog using ionic framework. Please help me and suggest where I am going wrong.
There was problem in the Facebook app-id. It is working fine now. Make sure you generate the correct key hash for the settings of Facebook app_id.
Suggest some working examples for android titanium Twitter integration.
I already tried some sample like Birdhouse, Social java script file but with that i didn't get the required output.
i just want to post a text through my titanium android app into twitter. May I know what is the correct way to achieve my objective?
Thanks in advance
Use social_plus.js it works for both android and iOS
https://github.com/aaronksaunders/test_social
Thanks
My Problem Get Solved by the Below Code
var social = require('alloy/social').create({
consumerSecret: 'consumer-secret',
consumerKey: 'consumer-key'
});
// If not authorized, get authorization from the user
if(!social.isAuthorized()) {
social.authorize();
}
// Post a message
// Setup both callbacks for confirmation
social.share({
message: "Salut, Monde!",
success: function(e) {alert('Success!')},
error: function(e) {alert('Error!')}
});
// Deauthorize the application
social.deauthorize();
Why don't you create a intent share menu ? It allows users to send content on all installed
apps that are able to share content. (email, sms, hangout, facebook...and twitter)
var createShareMenu = function(){
var subject = 'My subject';
var text = 'My text';
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_SEND,
type: "text/plain",
});
intent.putExtra(Ti.Android.EXTRA_TEXT,text);
intent.putExtra(Ti.Android.EXTRA_SUBJECT,subject);
var share = Ti.Android.createIntentChooser(intent,'Share');
return share;
};
and to show the share apps menu :
shareButton.addEventListener('click', function() {
var share = createShareMenu();
var activity = win.getActivity();
activity.startActivity(share);
});