iOS Facebook Native Share Dialog : initial text - ios

I'm using Facebook Native Share Dialog in my iOS app. I give the initial text, but when dialog pop up, it add the post URL to my initial text. How can I solve this problem? Here the code.
BOOL displayedNativeDialog =
[FBNativeDialogs
presentShareDialogModallyFrom:self
initialText:#"Say something about this..."
image:[UIImage imageWithData:imageData]
url:[NSURL URLWithString:activityUrl]
handler:^(FBNativeDialogResult result, NSError *error) {
if (error) {
} else {
if (result == FBNativeDialogResultSucceeded) {
} else {
}
}
}];

If you're sharing a URL (link share) and the image is inside that link, then just set the image parameter to nil. Then the post URL will not be added to the initial text. If you provide an image, it's as if you're sharing a photo and adding the link (and text) as photo caption info.
So based on what you're trying to do, select the option that works for you, i.e. is it a link share or a photo share.

Related

How to get initial link for iOS using react native firebase dynamic links?

I am using react-native-firebase:: 5.6.0, I am having issue while getting initial link for iOS device. On android it's working fine. I am using "Firebase Dynamic Links" to redirect user inside login screen of my app if in case he is not logged in inside app, otherwise just opening app if he is already logged in.
It's working for android app but having an issue with ios app. I have used two function one is the get dynamic link if app is closed "getInitialLink" and another one is to check when app is opened "onLink".
This is function I am using after closing splash screen, only called once when opening app from closing state.
firebase.links().getInitialLink().then((url) => {
if (url && url === 'https://mycustomdomain.co.in') {
navigationToScreen(AUTH, INITIAL_SCREEN);
} else {
// INITIALIZE APP HERE
}
});
If app already opened I am getting dynamic link url value inside this function::
this.unsubscribeHandleOpenAppDynamicLinks = firebase.links().onLink(async (url) => {
let isLoggedIn = await AsyncStorage.getItem(LocalStorageKeys.IS_LOGGEDIN);
if (url) {
if ( isLoggedIn !== 'yes' && url === 'https://mycustomdomain.co.in') {
navigationToScreen(AUTH, INITIAL_SCREEN);
}
}
});
and clearing that listener on componentWillUnmount:: this.unsubscribeHandleOpenAppDynamicLinks();
In case of iOS only "onLink" function is working and I am
getting url value as "undefined". getInitialLink() function will
returns the URL that the app has been launched from. If the app was
not launched from a URL the return value will be null, but I am
getting "undefined" even when launching an app from url in case of iOS
only. I am getting url inside onLink() in case of iOS when app is
launched. Why this is happening??
Please suggest what I am doing wrong here.
If getInitialLink method does not work, it is either because of improper linking or due to Expo runtime. As an alternative, use Linking.getInitialURL method to get the initial URL. This requires a little bit of native code as well. This is because Linking module does not know how to interpret the shortened URL. So, we call the resolveShortLink method of Firebase SDK to get the embedded deep link. Once we receive the embedded deep link, we can handle it as usual in our app.
The native source code is documented in this article. But for completeness, I will post it here.
#import "FDLResolver.h"
#import <React/RCTLog.h>
#implementation FDLResolver
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(resolveShortLink:(NSString *)shortLink :(RCTPromiseResolveBlock)resolve
:(RCTPromiseRejectBlock)reject)
{
id completion = ^(NSURL *_Nullable dynamicLink, NSError *_Nullable error) {
if (!error && dynamicLink) {
resolve(dynamicLink.absoluteString);
} else {
reject(#"Error", #"Error in getting dynamic link", error);
}
};
NSURL *shortLinkURL = [NSURL URLWithString:shortLink];
[[FIRDynamicLinks dynamicLinks] resolveShortLink:shortLinkURL completion:completion];
}
#end
And Linking module code is below.
Linking.getInitialURL().then(url => {
if (url && url.includes('page.link')) {
const shortLink = url.replace('exps', 'https')
NativeModules.FDLResolver.resolveShortLink(shortLink)
.then(link => {
const linkParts = link.split('?')
const query = qs.parse(linkParts[1])
this.parseRouteUrl(query.deep_link_id)
})
}
})

How to open salesforce login screen within the app

I am using salesforce oauth connected app setup. When I launch the app it redirects me to login in the safari in app browser. How to control this? Do I need to use any salesforce library like zksforce.
I followed these steps to create a project: https://developer.salesforce.com/docs/atlas.en-us.mobile_sdk.meta/mobile_sdk/ios_new_force_project.htm
Please suggest me which is the right way to display login screen in a native app.
There is no way to open login screen native -as far as I know :)-
You should set properties first as :
[SalesforceSDKManager sharedManager].connectedAppId = RemoteAccessConsumerKey;
[SalesforceSDKManager sharedManager].connectedAppCallbackUri = OAuthRedirectURI;
[SalesforceSDKManager sharedManager].authScopes = #[ #"web", #"api" ];
you can set callback properties if necessary :
[SalesforceSDKManager sharedManager].postLaunchAction = ^(SFSDKLaunchAction launchActionList) {
};
[SalesforceSDKManager sharedManager].launchErrorAction = ^(NSError *error, SFSDKLaunchAction launchActionList) {
};
And Then you should call :
[[SalesforceSDKManager sharedManager] launch];

Google API Bug - Attribution Inconsistency

Fetching photo data for a place using Google Places API HTTP web service call URL,
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=<LOCATION>&radius=<RADIUS>&sensor=false&key=<API_KEY>
yields the expected callback. Here is the response from a request I am using for testing.
2017-09-19 11:20:32.968347-0400 <MY_APP_NAME>[7502:2809094] Places Found: (
{
...
...
photos = (
{
height = 5312;
"html_attributions" = (
"leah steen"
);
"photo_reference" = "CmRaAAAAcppPDrYGBnLqlyYQ_EMmsvgKXXpVjp0drGkJPWLBwlSzrWzuhtFFGCzQPl1pSez92QVktthtaMSsV1IlAWMIMPboycElhruKgUg-KFHWWrhLKOR6h8GGiR349rhokAFJEhApc7ghYIH0guUQBGJi1bKBGhQMcElN7-lSBzvCgAG3vVzANLkf6A";
width = 2988;
}
);
...
...
}
)
As you can see, this place has a photo dictionary containing an html_attributions value for the associated image, which I am handling appropriately throughout my application.
ISSUE:
When I fetch the photo data for the same place, by using the place_id, I get this for the photo and attribution:
2017-09-19 11:22:08.548253-0400 <MY_APP_NAME>[7502:2809094] photo data: (
"<UIImage: 0x17048b720> size {169, 300} orientation 0 scale 2.000000",
"leah steen{\n}"
)
I receive of course the same photo, but an attribution WITHOUT a link. As you can see from my other method using the web service, the photo for this place does indeed have an attribution with a link.
I am at a loss. How am I supposed to get the full attribution from Google if their iOS SDK does not return the same data?
CODE:
Using Google's other suggested method for fetching photo data for a place via the place_id you can obtain the image and the images attribution (if it has one).
I fetch the data using these two methods as Google asks:
- (void)lookUpPhotosForPlaceID:(NSString *)placeID
callback:(GMSPlacePhotoMetadataResultCallback)callback;
- (void)loadPlacePhoto:(GMSPlacePhotoMetadata *)photo
callback:(GMSPlacePhotoImageResultCallback)callback;
Here is the code I use for fetching the photo data.
// Look up photos for the place
[[GMSPlacesClient sharedClient] lookUpPhotosForPlaceID:placeID callback:^(GMSPlacePhotoMetadataList * _Nullable photos, NSError * _Nullable error) {
if (error != nil) {
response(error, NULL);
return;
}
if (photos.results.count > 0) {
GMSPlacePhotoMetadata *metaData = photos.results.firstObject; // Using the first photo
// Load the photo
[[GMSPlacesClient sharedClient] loadPlacePhoto:metaData constrainedToSize:<SOME_SIZE> scale:[UIApplication sharedApplication].keyWindow.screen.scale callback:^(UIImage * _Nullable photo, NSError * _Nullable error) {
if (error) {
response(error, NULL);
return;
}
NSArray *photoData = #[photo, metaData.attributions];
response(nil, photoData);
}];
}
else response(error, NULL);
}];
EDIT:
For reference, as Google does inform it's users that this data may be subject to change, and that multiple callbacks should return the same data. Yet multiple calls using different API's do not...
You can do couple of thing to verify correct behaviour:
You can switch back to first API and see whether it actually returns it again. Because doc says:
Multiple calls of this method will probably return the same photos
each time. However, this is not guaranteed because the underlying data
may have changed.
Second you can check the callback behaviour if you are losing some data when callback is called in line
NSArray *photoData = #[photo, metaData.attributions];
At this point it me be loosing attributed string but only retains plain text(leah steen).
Good way to check this metaData is before loadPlacePhoto:callback:

Why is EDAMNote.content is null?

I want to get the content of the first note in the notebook. I set a content and title. Title is ok but content attribute is null.
EDAMNoteFilter *filter = [[EDAMNoteFilter alloc] init];
[[EvernoteNoteStore noteStore] findNotesWithFilter:filter
offset:0
maxNotes:10
success:^(EDAMNoteList *result) {
if(result.totalNotes>0)
{
EDAMNote *note=result.notes[0];
NSLog(#"%#",[note title]);
NSLog(#"%#",[note content]);
}
}
failure:^(NSError *error) {
// FIXME:zxx 2012-9-26 Alert user error occurs
NSLog(#"Error occurs when retreiving notes: %#", error);
}];
If you read the documentation for the findNotesWithFilter method in the Evernote SDK you will see the following -
Discussion
Used to find a set of the notes from a user’s account based on various
criteria specified via a NoteFilter object.
The Notes (and any embedded Resources) will have empty Data bodies for contents, resource data, and resource recognition fields. These values must be retrieved individually.
You need to retrieve the content using a method such as getNoteWithGuid:withContent:withResourcesData:withResourcesRecognition:withResourcesAlternateData:success:failure:

Post text/message on friend's wall using FBShareDialogParams on ios 7 - objective c

I can share link, with name, caption and description on Facebook friend's wall by using FBShareDialogParams, But I can't share text message with this link, or even only text without link.
For this i use below code:
FBShareDialogParams *sharedParams = [[FBShareDialogParams alloc] init];
sharedParams.friends = fpc.selection;
NSURL *candidateURL = [NSURL URLWithString:_contentDataToShare];
sharedParams.description = #"See this link ..";
sharedParams.link = candidateURL;
if ([FBDialogs canPresentShareDialogWithParams:sharedParams]) {
[FBDialogs presentShareDialogWithParams:sharedParams clientState:nil
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error)
{
NSLog(#"ERROR : %#",error);
}
else
{
NSLog(#"Posted AL7");
}
}];
}
I'm working on IOS 7. and Facebook SDK 3.13.1.
I can post link successfully, but i need to post text message too, how can i do that ?
Event text only, or with link.
Thank you,
Prefilling the message is against Facebook Platform policies, which is why the SDK does not allow you to do it. The message MUST be user provided.
For more info, if any one need it..
https://developers.facebook.com/policy/
From section IV.2 : "You must not pre-fill any of the fields associated with the following products, unless the user manually generated the content earlier in the workflow: Stream stories (user_message parameter for Facebook.streamPublish and FB.Connect.streamPublish, and message parameter for stream.publish), Photos (caption), Videos (description), Notes (title and content), Links (comment), and Jabber/XMPP."

Resources