ฉันจะเพิ่มรูปภาพและข้อความใน Whatsapp ด้วยความช่วยเหลือในการเขียนโค้ด ฉันจะทำอย่างไรเพื่อแก้ไขปัญหาของฉัน?
แชร์รูปภาพและข้อความบน WhatsApp ใน IOS โดยทางโปรแกรมหรือไม่
comment
คุณได้ตรวจสอบโพสต์นี้แล้ว - stackoverflow.com/questions/19524635/ ?
- person May13ank   schedule 19.06.2015
comment
@AshishKakkad ฉันต้องการแชร์รูปภาพพร้อมข้อความเช่น (รูปภาพพร้อมคำบรรยาย)
- person Anil Jangir   schedule 19.06.2015
คำตอบ (1)
คุณสามารถโพสต์รูปภาพหรือข้อความบน WhatsApp แต่คุณจะไม่โพสต์ทั้งสองอย่างพร้อมกันเนื่องจาก whatsapp ไม่มี API ใด ๆ ที่คุณสามารถเพิ่มคำบรรยายและโพสต์รูปภาพพร้อมข้อความได้
ต่อไปนี้เป็นตัวอย่างสำหรับการโพสต์รูปภาพจากแอป iPhone ไปยัง Whatsapp โดยเป็นเอกสาร WhatsApp:
ในไฟล์ ViewController.h:
@interface ViewController : UIViewController
{
}
@property(nonatomic,retain) UIDocumentInteractionController *documentationInteractionController;
ในไฟล์ ViewController.m:
- (IBAction)bocClick:(UIButton *)sender {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *getImagePath = [documentsDirectory stringByAppendingPathComponent:@"savedImage.png"]; //here i am fetched image path from document directory and convert it in to URL and use bellow
NSURL *imageFileURL =[NSURL fileURLWithPath:getImagePath];
NSLog(@"imag %@",imageFileURL);
self.documentationInteractionController.delegate = self;
self.documentationInteractionController.UTI = @"net.whatsapp.image";
self.documentationInteractionController = [self setupControllerWithURL:imageFileURL usingDelegate:self];
[self.documentationInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
}
- (UIDocumentInteractionController *) setupControllerWithURL: (NSURL*) fileURL
usingDelegate: (id ) interactionDelegate {
self.documentationInteractionController =
[UIDocumentInteractionController interactionControllerWithURL: fileURL];
self.documentationInteractionController.delegate = interactionDelegate;
return self.documentationInteractionController;
}
person
Nitin Gohel
schedule
19.06.2015