嗨,现在我正在尝试在我们的应用中集成什么应用
我已经完成了Tweet
: - 在这个应用程序中,我创建了两个按钮 一个(chooseImagePressed)按钮是选择图像形式的本地文件然后 然后第二个(tweetButtonPressed)这是将图像发布到Tweeter
- (IBAction)tweetButtonPressed:(id)sender
{
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:@"Look at this nice picture!"];
[tweetSheet addImage:self.imageView.image];
[self presentViewController:tweetSheet animated:YES completion:nil];
}
else
{
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Error"
message:@"please setup Twitter"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}
- (IBAction)chooseImagePressed:(id)sender
{
self.pickerController = [[UIImagePickerController alloc] init];
self.pickerController.delegate = self;
self.pickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:self.pickerController animated:YES completion:nil];
}
#pragma mark
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info;
{
self.imageView.image = [info objectForKey:UIImagePickerControllerOriginalImage];
[self dismissViewControllerAnimated:YES completion:nil];
}
请告诉我如何将应用内容整合到我们的应用中
请告诉我这是否可能
谢谢
答案 0 :(得分:4)
否,无法as like tweeter and Facebook api
。但是如果已经安装了whatsapp,你可以从你的应用程序发送消息到whatsapp
NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=Hello%2C%20World!"];//use this method stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding to convert it with escape char
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
}
但如果你想分享文件,图片,视频等文件,你可以通过UIDocumentInteractionController.发送它
注意: whatsapp应安装在两个以上,否则你无法做任何事情。 See this for current whatsApp doc.
答案 1 :(得分:2)
简单整合
var whatsappURL = URL(string: "https://api.whatsapp.com/send?phone=9530670491&text=hello")
if UIApplication.shared.canOpenURL(whatsappURL) {
UIApplication.shared.openURL(whatsappURL!)
}
<强>夫特强>
{
"Sid": "RestrictCreationToNamePolicy",
"Action": [
"s3:CreateBucket"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::company-dbbackup-*"
}
{
"Sid": "AllowListingOfBuckets",
"Action": [
"s3:ListAllMyBuckets"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::*"
}
答案 2 :(得分:1)
您将在此处获得更多输入:
http://www.whatsapp.com/faq/en/iphone/23559013
- 这用于与WhatsApp共享任何Image / vodeo。 - 您需要在代码中执行UIDocumentInteractionController类参考。 - 您需要将映像保存到磁盘,然后使用该文件URL创建UIDocumentInteractionController。 - 以下是相同的代码捕捉,你可以与WhatsApp共享图像。
//Path of the image which is present in bundle
NSString* path = [[NSBundle mainBundle] pathForResource:@"images" ofType:@"jpg”];
/* here you can also give the path of image which is saved on disk.*/
if (path) {
NSURL* url = [NSURL fileURLWithPath:path];
UIDocumentInteractionController* docController = [UIDocumentInteractionController interactionControllerWithURL:url];
docController.delegate = self;
[docController presentPreviewAnimated:YES];
}
用于文本共享
//This is sharing text encoding with NSUTF8StringEncoding
NSString* strSharingText = [txtWhatsApp.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//This is whatsApp url working only when you having app in your Apple device
NSURL *whatsappURL = [NSURL URLWithString:[NSString stringWithFormat:@"whatsapp://send?text=%@",strSharingText]];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
}
答案 3 :(得分:1)
我更喜欢这种documented方法:
package com.example;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
@Configuration
@ComponentScan(basePackages = { "com.example" })
@PropertySource(ignoreResourceNotFound = true, value = "classpath:/application.props")
public class MainDriver {
@Autowired
private Environment env;
@Autowired
private ApplicationContext ctx;
@Autowired
private ConfigurableEnvironment cenv;
public static void main(String[] args) {
ApplicationContext ctx = new AnnotationConfigApplicationContext(MainDriver.class);
MainDriver l = ctx.getBean(MainDriver.class);
System.out.println("In main() the ctx is " + ctx);
l.test();
}
public void test() {
System.out.println("hello");
System.out.println("env is " + env);
System.out.println("cenv is " + cenv);
System.out.println("ctx is" + ctx);
}
}
答案 4 :(得分:0)
对于Swift 4.2及更高版本
let whatsAppURL = URL(string: "https://api.whatsapp.com/send?phone=0123456")
if UIApplication.shared.canOpenURL(whatsAppURL!)
{
UIApplication.shared.open(whatsAppURL!, options: [:], completionHandler: nil)
}