diff --git a/src/ApnMessage.php b/src/ApnMessage.php index c1f8b22..54b9d67 100644 --- a/src/ApnMessage.php +++ b/src/ApnMessage.php @@ -210,9 +210,11 @@ public function sound(null|string|Sound $sound = 'default'): self /** * Set the interruptionLevel of the notification. */ - public function interruptionLevel(?string $interruptionLevel = 'active'): self + public function interruptionLevel(string|ApnMessageInterruptionLevel|null $interruptionLevel = 'active'): self { - $this->interruptionLevel = $interruptionLevel; + $this->interruptionLevel = $interruptionLevel instanceof ApnMessageInterruptionLevel + ? $interruptionLevel->value + : $interruptionLevel; return $this; } diff --git a/src/ApnMessageInterruptionLevel.php b/src/ApnMessageInterruptionLevel.php new file mode 100644 index 0000000..75eaf1b --- /dev/null +++ b/src/ApnMessageInterruptionLevel.php @@ -0,0 +1,11 @@ +assertEquals($message, $result); } + /** @test */ + public function it_can_set_interruption_level_as_enum() + { + $message = new ApnMessage; + + $result = $message->interruptionLevel(ApnMessageInterruptionLevel::Critical); + + $this->assertEquals('critical', $message->interruptionLevel); + $this->assertEquals($message, $result); + } + /** @test */ public function it_can_set_sound_to_default() {