Skip to content

Commit

Permalink
Merge pull request #65 from hstrowd/apns-topic-support-for-certificates
Browse files Browse the repository at this point in the history
APNS Topic Support for Certificate Integrations
  • Loading branch information
edamov authored Aug 5, 2019
2 parents c0005d3 + 7cf61d0 commit de4578d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/AuthProvider/Certificate.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ class Certificate implements AuthProviderInterface
*/
private $certificateSecret;

/**
* The bundle ID for app obtained from Apple developer account.
*
* @var string
*/
private $appBundleId;

/**
* This provider accepts the following options:
*
Expand All @@ -48,6 +55,7 @@ private function __construct(array $options)
{
$this->certificatePath = $options['certificate_path'] ;
$this->certificateSecret = $options['certificate_secret'];
$this->appBundleId = $options['app_bundle_id'] ?? null;
}

/**
Expand Down Expand Up @@ -75,5 +83,8 @@ public function authenticateClient(Request $request)
CURLOPT_SSL_VERIFYPEER => true
]
);
$request->addHeaders([
"apns-topic" => $this->appBundleId
]);
}
}
11 changes: 11 additions & 0 deletions tests/AuthProvider/CertificateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,15 @@ public function testCreatingCertificateAuthProvider()

$this->assertInstanceOf(AuthProviderInterface::class, $authProvider);
}

public function testCreatingCertificateAuthProviderWithAppBundleId()
{
$options = [];
$options['certificate_path'] = __DIR__ . '/../files/certificate.pem';
$options['certificate_secret'] = 'secret';
$options['appBundleId'] = 'com.apple.test';
$authProvider = AuthProvider\Certificate::create($options);

$this->assertInstanceOf(AuthProviderInterface::class, $authProvider);
}
}

0 comments on commit de4578d

Please sign in to comment.