2015-09-25 60 views
1

我想打開whatsapp對話/聊天對於特定的聯繫人。 而不是打開所需的聊天,它只會打開應用程序。 不知道什麼是錯:使用Abid打開WhatsApp對話不起作用

let URLString = "whatsapp://send?abid=\(ID);text=lOL;" 
     UIApplication.sharedApplication().openURL(NSURL(string: URLString)!) 

URLString值:whatsapp://send?abid=414;text=lOL

有什麼建議?

+0

那麼它只能打開應用程序? – Xrait

+0

它只是打開whatsapp沒有任何關係的阿比德,就像顯示應用程序的主頁@LGL –

+0

那裏的API在哪裏?你能告訴我嗎? – Xrait

回答

3

更新您的URL這樣的:

whatsapp://send?abid=\(ID)&text=lOL 

HERE來源。

+0

謝謝!作品! –

+0

嗨,什麼是ID?我試過用戶名,但它不起作用! – Mariam

+0

ABID(ABRecordID)是標識記錄的整數。你可以查看文檔https://developer.apple.com/library/ios/documentation/AddressBook/Reference/ABRecordRef_iPhoneOS/#//apple_ref/c/tdef/ABRecordID – andreacipriani

1

試試這個,並檢查是否UIApplication並打開URL。

let whatsAppURL: NSURL = NSURL(string: "whatsapp://send?abid=\(ID)&text=lOL") 
if UIApplication.sharedApplication().canOpenURL(whatsAppURL){ 
    UIApplication.sharedApplication().openURL(whatsAppURL) 
} 
+0

以及:) –