1

我試圖使用Urban Airship PHP libraray來實現深層鏈接消息傳遞,但我找不到文檔或相關代碼。 現在我有這個如何使用Urban Airship與PHP深度鏈接

require_once 'vendor/autoload.php'; 
use UrbanAirship\Airship; 
use UrbanAirship\AirshipException; 
use UrbanAirship\UALog; 
use UrbanAirship\Push as P; 
use Monolog\Logger; 
use Monolog\Handler\StreamHandler; 

$droidToken = "my-device-token" ; 

UALog::setLogHandlers(array(new StreamHandler("php://stdout",Logger::INFO))); 
$airship = new Airship("key", "Secret"); 

    $req = $airship->push() 
      ->setAudience(P\apid($droidToken)) 
      ->setMessage(P\message("This is the title", 
       "<html><body><h1>This is the message</h1></body></html>", 
       "text/html", 
       "utf-8", 
       array("value"=>"agh://myAppName.app/preferences23"))) 
      ->setDeviceTypes(P\all); 
     $response = $req->send(); 

其中agh://myAppName.app是模板和preferences23值應該是

understand我需要將其添加在actions標籤:

{ 
    "actions": { 
     "open": { 
     "type": "deep_link", 
     "content": "prefs" 
     } 
    } 
} 

,但在哪裏?

當我運行上面的代碼時,我收到了手機中的消息,但消息中沒有深層鏈接。

回答

0

找到了! 你只需要一個action添加到通知結構

type: deep_link, content:是深層鏈接網址。

$req = $airship->push() 
     ->setAudience(P\apid($deviceToken)) 
     ->setNotification(P\notification("my message', 
             array("actions" => array(
                "open" => array(
                 "type" => "deep_link", 
                 "content" => "js://myapp.app/deepLink" 
                ))))) 
     ->setDeviceTypes(P\all); 
+0

從哪裏可以找到它「js://myapp.app/deepLink」? – anil

+0

從哪裏我可以找到內容密鑰的深層鏈接網址? – anil