how to generate qr code image, with vcf file ios - ios

i have contact details as string
BEGIN:VCARD
VERSION:3.0
N:Doe;John
FN:John Doe
ORG:Company
TITLE:CEO
ADR;TYPE=WORK:;;1234 Any Street;Beverly Hills;CA;90210;USA
TEL;TYPE=WORK,VOICE:1-555-555-4321
TEL;TYPE=CELL,VOICE:1-555-555-1234
EMAIL;TYPE=PREF,INTERNET:johndoe#yourcompany.com
URL;TYPE=WORK:http://yourcompany.com
END:VCARD
how to make qr code image with above mention information, programmatically.

i ended up find my own solution,using Zxing libary
ZXMultiFormatWriter *writer = [ZXMultiFormatWriter writer];
NSString *str=#"BEGIN:VCARD\r\nVERSION:2.1\r\nN:Satya;Dash;;;\r\nADR;DOM;PARCEL;HOME:;;****Mission Street;Cuttack City;Orissa;94014;INDIA.\r\nEMAIL;INTERNET:satya#domain.com\r\nTEL;CELL:22-122-4567\r\nTEL;CELL:133-156-3345\r\nEND:VCARD";
ZXBitMatrix* result = [writer encode:str
format:kBarcodeFormatQRCode
width:320
height:300
error:&error];
if (result) {
UIImage* uiImage = [[UIImage alloc] initWithCGImage:[[ZXImage imageWithMatrix:result] cgimage]];
[self.imageView setImage:uiImage];
[self.lbl setText:[NSString stringWithFormat:#"%#",str]];
} else {
NSString *errorMessage = [error localizedDescription];
NSLog(#"error is %#",errorMessage);
}
when you will scan qr image it will return vcard version 2.1

I m using codeignitor for this.This is the library link (https://github.com/dwisetiyadi/CodeIgniter-PHP-QR-Code).i insert a short url in this.generated by yourls(yourls.org/#API).when user scans the code.mobile ask to open the link and when user opens the link.i take him to my webpage where whole qr code vcf information is shown link name address etc and a download button.when user click on download button (.vcf) file is gets download which can be used in mobile as well as outlook.

Related

How do I upload image Podio SDK using Objective-C (iOS)?

I am integrating the Podio SDK. I am getting all data item values and updating also, but images won't upload. Any idea? I don't know how to upload an image on Podio SDK.
NSData *data = UIImageJPEGRepresentation(self.ImgView_Sign.image, 0.8f);
[[[PKTFile uploadWithData:data fileName:#"mobi.jpg"] pipe:^PKTAsyncTask *(PKTFile *file){
PKTItem *item = [PKTItem itemForAppWithID:431525395];
item[#"title"] = #"CHEKRI";
item[#"signautre"] = file;
return [item save];
}] onSuccess:^(PKTItem *item){
NSLog(#"PKT FILE is %#",item);
} onError:^(NSError *error){
NSLog(#"Error file %#",error);
}];
Please use below code might be work for you.
UIImage *image = [UIImage imageNamed:#"some-image.jpg"];
NSData *data = UIImageJPEGRepresentation(image, 0.8f);
PKTAsyncTask *uploadTask = [PKTFile uploadWithData:data fileName:#"image.jpg"];
[uploadTask onComplete:^(PKTFile *file, NSError *error) {
if (!error) {
NSLog(#"File uploaded with ID: %#", #(file.fileID));
}
}];
Adding an image to an image field is a two-step process.
First you must upload the file. https://developers.podio.com/doc/files/upload-file-1004361 will give you a file object with a file_id you need in step two.
Step two is to create a new item, update an item or update the field value. Here you pass the file_id as a the value for the field.
We have a general tutorial on working with items here https://developers.podio.com/examples/items
Working with file_ids for image fields is not different than the other field types. Just as you use profile_ids to work with Contact fields you use file_ids to work with image fields.
Original source: https://help.podio.com/hc/en-us/community/posts/200516608-API-image-upload-to-Image-Field

iOS Share GIF (animated image) not Working

It's been almost 2 days that i'm looking to find a solution to my problem but i wasn't successful , i want to share GIF (animated image) on Facebook, Twitter, Email, WhatsApp , using "UIActivityViewController".
This is my code :
NSURL *imagePath = [NSURL URLWithString:#"http://sth.gif"];
NSData *animatedGif = [NSData dataWithContentsOfURL:imagePath];
NSArray *sharingItems = [NSArray arrayWithObjects: animatedGif,stringToShare, nil];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:sharingItems applicationActivities:nil];
When i share in Email its animated and its working perfect , but in Twitter , Facebook , whatsApp Gifs are not animated and its like an image ...
I already read all Stack-overflow questions about the same problem Like this or this or this but its not working for me.
So far base on days research found out that :
TWITTER : For share a GIF on twitter had to use twitter API and create a multipart request to achieve the goal and its working very well.
FACEBOOK : I did share some GIF on Facebook using FACEBOOKSHAREKIT , but i don't know why sometimes Gifs are animated, sometimes not.
INSTAGRAM : To share gif on Instagram had to convert GIFS to MP4 (or any other video formats accepted by Instagram) then save it into camera roll then share it , It is little twisted but its working very well.
WHATSAPP : It not supporting GIF at all. READ THE UPDATE
To do all of this i couldn't use "UIActivityViewController" , so decided to create a custom share page. if anybody know something to add here , to help me and others please tell me (especially about Facebook).
Thanks in advance
UPDATE
WHATSAPP : Thanks to #AmmarShahid, as he mentioned in comments, Whatsapp now supports gif.
Encountered the similar problem and Googled a lot but still not a perfect solution, the best I came up is here:
Use UIActivityItemProvider and extend - (id)item {} for different UIActivityType:
Twitter: The default UIActivityViewController Twitter share doesn't support it yet which it will "scale down" it as a still JPG. However somehow it works for GIF less than 100kb (tested in iOS 9) and I don't know why. Therefore, I have to use SLRequest to upload the GIF as taught in here. When the SLRequest is done and return, dismiss the UIActivityViewController. The downside of that is no preview share sheet and users cannot type their own message anymore.
Facebook: It's actually much easier! Just upload the GIF to Giphy, then provide the Giphy URL to UIActivityViewController instead of the file contents, Facebook will recognize it and show the animated GIF
- (id)item
{
if ([self.activityType isEqualToString:UIActivityTypePostToFacebook]) {
// Upload to Giphy
...
return [NSURL URLWithString:giphyURL];
}
if ([self.activityType isEqualToString:UIActivityTypePostToTwitter]) {
// Use SLRequest to share instead
...
// Dismiss the UIActivityViewController (I am using Unity)
[UnityGetGLViewController() dismissViewControllerAnimated:NO completion: NULL];
return nil;
}
}
full code is in my GitHub, I am actually a iOS newb so some experts please correct me and the code if possible
// Share GIF File: WhatsApp
NSURL *imageUrl =[self.ImageArray objectAtIndex:currentPhotoIndex];
NSString *path=imageUrl.absoluteString;
NSArray *strings = [path componentsSeparatedByString:#"/"];
NSString *mygif=[strings objectAtIndex:strings.count-1];
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *dataPath = [documentsPath stringByAppendingPathComponent:#"/MrHRamani"];
NSString *filePath = [dataPath stringByAppendingPathComponent:mygif];
NSURL *urll=[NSURL fileURLWithPath:filePath];
NSLog(#"imag %#",imageUrl);
self.documentationInteractionController.delegate = self;
self.documentationInteractionController.UTI = #"net.whatsapp.image";
self.documentationInteractionController = [self setupControllerWithURL:urll usingDelegate:self];
[self.documentationInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];

Send NSData via Airdrop

I've got a (for me) big problem.
I want to send a vcf-file with airdrop from my own app to another iOS device. I've got a NSData object, which i should convert to a vcf file, and this I should send with airdrop to another IOS device.
The NSData object works fine, i can send a vcc file with email, but with airdrop I left my limit.
I tried everything i found here in the forum and on developer.apple.com. But nothing works, I think the reason is, that i have no idea how too start the fix the problem.
Has anybody any idea how i can realize it?
THANKS
I believe this is roughly what you are looking for:
NSString *contactName = nil; // name of person in vcard
NSData *vcfData = nil; // vcard data
NSURL *fileURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:#"%#.vcf", contactName]]];
NSError *writeError;
if ([vcfData writeToURL:fileURL options:NSDataWritingAtomic error:&writeError]) {
NSArray *activityItems = #[fileURL];
UIActivityViewController *avc = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:avc animated:YES completion:nil];
} else {
// failed, handle errors
}
If you still want to support providing NSData to some of the activities you will have to create some objects that conforms to UIActivityItemSource protocol and have some of them return nil where appropriate (see this SO for more details on that). You might find the AirDrop sample code project from Apple helpful too.

How Do I save the user's image fetched from fbprofilepictureview using the Facebook SDK

So I'm implementing the Facebook login button in an iOS app I'm currently working on, I'm trying to save the user's profile picture that's accessed using this line;
self.profilePicture.profileID = user.id;
I haven't had any luck storing that image for use elsewhere in the app. I have tried a number of methods including this approach
imageUrl=[NSString stringWithFormat:#"https://graph.facebook.com/%#/picture?redirect=true", user.username];
Any help is welcome!
You need to use user.objectID and not user.username.
You can also use my drop-in replacement for FBProfilePictureView, DBFBProfilePictureView. This exposes the imageView as a readonly property. Using that, your code would be something like this...
self.profilePicture.completionHandler = ^(DBFBProfilePictureView* view, NSError* error){
if(error) {
view.showEmptyImage = YES;
NSLog(#"Loading profile picture failed with error: %#", error);
} else {
UIImage *image = view.imageView.image;
NSData *imageData = UIImagePNGRepresentation(image);
[imageData writeToFile:filename atomically:NO];
}
};

iOS - Is it possible to rename image file name before saving it into iPhone device gallery from app?

Hey I'm new to iPhone and I have been trying to make an gallery kind of app. Basically, what I want to do is that i need to save all the captured images into a specific folder like a new album "My_App Images" related to our app name in iPhone device gallery, it's working for me, but I am having trouble to change the image file name, i don't know that Is it possible to specify a file name? Using iPhoto, currently i am getting image file name as "IMG_0094.jpg", can we change it with any other file name like "Anyfilename.png" format programmatically?
here is my code for saving images to the specific album :
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
[self.library saveImage:image toAlbum:#"My_App Images" withCompletionBlock:^(NSError *error) {
if (error!=nil) {
NSLog(#"Image saving error: %#", [error description]);
}
}];
[picker dismissViewControllerAnimated:NO completion:nil];
}
Any source or link for reference is appreciated. Thanks for the help!
There is a way to kinda do that, by setting the image IPTC metadata field "Object Name". If you later import the image to iPhoto, then this name will be used as its title.
See details (and code) at http://ootips.org/yonat/how-to-set-the-image-name-when-saving-to-the-camera-roll/ .
Do you meant,
// Build NSData in memory from the btnImage...
NSData* imageData = UIImageJPEGRepresentation(image, 1.0);
// Save to the default Apple (Camera Roll) folder.
[imageData writeToFile:#"/private/var/mobile/Media/DCIM/100APPLE/customImageFilename.jpg" atomically:NO];
Now adjust the path of folder as per your folder name...
Sorry to disappoint you, but it seems that you can not change the name of the photos, before or after saving, in the photo album, custom or not. Here is a post to explain it:
iOS rename/delete albums of photos
Edit
So, to clarify my comment, use the following override:
Download the NSMutableDictionary category for metadata of image here.
Also download the sample project CustomAlbumDemo from here and modify the NSMutableDictionary+ImageMetadata.m file in the CustomAlbumDemo project as:
-(void)saveImage:(UIImage*)image toAlbum:(NSString*)albumName withCompletionBlock:(SaveImageCompletion)completionBlock
{
//write the image data to the assets library (camera roll)
NSData* imageData = UIImageJPEGRepresentation(image, 1.0);
NSMutableDictionary *metadata = [[NSMutableDictionary alloc] init];
[metadata setDescription:#"This is my special image"];
[self writeImageDataToSavedPhotosAlbum:imageData metadata:metadata completionBlock:^(NSURL *assetURL, NSError *error) {
//error handling
if (error!=nil) {
completionBlock(error);
return;
}
//add the asset to the custom photo album
[self addAssetURL: assetURL
toAlbum:albumName
withCompletionBlock:completionBlock];
}];
}

Resources