Skip to content
This repository was archived by the owner on Jun 6, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Command/TestPushCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
Symfony\Component\Console\Input\InputInterface,
Symfony\Component\Console\Input\InputOption,
Symfony\Component\Console\Output\OutputInterface;
use RMS\PushNotificationsBundle\Message as PushMessage,
RMS\PushNotificationsBundle\Message\MessageInterface;
use RMS\PushNotifications\Message as PushMessage,
RMS\PushNotifications\Message\MessageInterface;

class TestPushCommand extends ContainerAwareCommand
{
Expand All @@ -30,7 +30,7 @@ protected function configure()
->setDescription("Sends a push command to a supplied push token'd device")
->addOption("badge", "b", InputOption::VALUE_OPTIONAL, "Badge number (for iOS devices)", 0)
->addOption("text", "t", InputOption::VALUE_OPTIONAL, "Text message")
->addArgument("service", InputArgument::REQUIRED, "One of 'ios', 'c2dm', 'gcm', 'mac', 'blackberry' or 'windowsphone'")
->addArgument("service", InputArgument::REQUIRED, "One of 'ios', 'c2dm', 'gcm', 'fcm', 'mac', 'blackberry' or 'windowsphone'")
->addArgument("token", InputArgument::REQUIRED, "Authentication token for the service")
->addArgument("payload", InputArgument::OPTIONAL, "The payload data to send (JSON)", '{"data": "test"}')
;
Expand Down Expand Up @@ -111,6 +111,11 @@ protected function getMessageClass($service)
$message = new PushMessage\AndroidMessage();
$message->setGCM(true);

return $message;
case "fcm":
$message = new PushMessage\AndroidMessage();
$message->setFCM(true);

return $message;
case "blackberry":
return new PushMessage\BlackberryMessage();
Expand Down
4 changes: 1 addition & 3 deletions DependencyInjection/Compiler/AddHandlerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface,
Symfony\Component\DependencyInjection\ContainerBuilder,
Symfony\Component\DependencyInjection\Definition,
Symfony\Component\DependencyInjection\Reference,
RMS\PushNotificationsBundle\Device\Types,
Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;

class AddHandlerPass implements CompilerPassInterface
Expand Down Expand Up @@ -53,7 +51,7 @@ public function process(ContainerBuilder $container)
}

// Required interface
$requiredInterface = 'RMS\\PushNotificationsBundle\\Service\\OS\\OSNotificationServiceInterface';
$requiredInterface = 'RMS\\PushNotifications\\Handlers\\NotificationHandlerInterface';
if (!$refClass->implementsInterface($requiredInterface)) {
throw new \UnexpectedValueException(sprintf(
'Notification service "%s" by id "%s" must be implements "%s" interface!' ,
Expand Down
26 changes: 26 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function getConfigTreeBuilder()
$this->addMac();
$this->addBlackberry();
$this->addWindowsphone();
$this->addWindows();

return $treeBuilder;
}
Expand Down Expand Up @@ -68,6 +69,13 @@ protected function addAndroid()
booleanNode("dry_run")->defaultFalse()->end()->
end()->
end()->
arrayNode("fcm")->
canBeUnset()->
children()->
scalarNode("api_key")->isRequired()->cannotBeEmpty()->end()->
booleanNode("use_multi_curl")->defaultValue(true)->end()->
end()->
end()->
end()->
end()->
end()
Expand Down Expand Up @@ -148,4 +156,22 @@ protected function addWindowsphone()
end()
;
}

/**
* Windows configuration
*/
protected function addWindows()
{
$this->root->
children()->
arrayNode('windows')->
children()->
scalarNode("timeout")->defaultValue(5)->end()->
scalarNode("sid")->isRequired()->cannotBeEmpty()->end()->
scalarNode("secret")->isRequired()->cannotBeEmpty()->end()->
end()->
end()->
end()
;
}
}
28 changes: 27 additions & 1 deletion DependencyInjection/RMSPushNotificationsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public function load(array $configs, ContainerBuilder $container)
$this->setWindowsphoneConfig($config);
$loader->load('windowsphone.xml');
}
if (isset($config['windows'])) {
$this->setWindowsConfig($config);
$loader->load('windows.xml');
}
}

/**
Expand Down Expand Up @@ -95,13 +99,27 @@ protected function setAndroidConfig(array $config)
$this->container->setParameter("rms_push_notifications.android.c2dm.password", $password);
$this->container->setParameter("rms_push_notifications.android.c2dm.source", $source);

// DEFINE PARAMETERS
$this->container->setParameter("rms_push_notifications.android.gcm.api_key", null);
$this->container->setParameter("rms_push_notifications.android.gcm.use_multi_curl", null);
$this->container->setParameter("rms_push_notifications.android.gcm.dry_run", null);
$this->container->setParameter("rms_push_notifications.android.fcm.api_key", null);
$this->container->setParameter("rms_push_notifications.android.fcm.use_multi_curl", null);

// GCM
$this->container->setParameter("rms_push_notifications.android.gcm.enabled", isset($config["android"]["gcm"]));
if (isset($config["android"]["gcm"])) {
$this->container->setParameter("rms_push_notifications.android.gcm.api_key", $config["android"]["gcm"]["api_key"]);
$this->container->setParameter("rms_push_notifications.android.gcm.api_key", isset($config["android"]["gcm"]["api_key"]) ? $config["android"]["gcm"]["api_key"] : null);
$this->container->setParameter("rms_push_notifications.android.gcm.use_multi_curl", $config["android"]["gcm"]["use_multi_curl"]);
$this->container->setParameter('rms_push_notifications.android.gcm.dry_run', $config["android"]["gcm"]["dry_run"]);
}

// FCM
$this->container->setParameter("rms_push_notifications.android.fcm.enabled", isset($config["android"]["fcm"]));
if (isset($config["android"]["fcm"])) {
$this->container->setParameter("rms_push_notifications.android.fcm.api_key", $config["android"]["fcm"]["api_key"]);
$this->container->setParameter("rms_push_notifications.android.fcm.use_multi_curl", $config["android"]["fcm"]["use_multi_curl"]);
}
}

/**
Expand Down Expand Up @@ -192,4 +210,12 @@ protected function setWindowsphoneConfig(array $config)
$this->container->setParameter("rms_push_notifications.windowsphone.enabled", true);
$this->container->setParameter("rms_push_notifications.windowsphone.timeout", $config["windowsphone"]["timeout"]);
}

protected function setWindowsConfig(array $config)
{
$this->container->setParameter("rms_push_notifications.windows.enabled", true);
$this->container->setParameter("rms_push_notifications.windows.timeout", $config["windows"]["timeout"]);
$this->container->setParameter("rms_push_notifications.windows.sid", $config["windows"]["sid"]);
$this->container->setParameter("rms_push_notifications.windows.secret", $config["windows"]["secret"]);
}
}
14 changes: 0 additions & 14 deletions Device/Types.php

This file was deleted.

26 changes: 0 additions & 26 deletions Device/iOS/Feedback.php

This file was deleted.

7 changes: 0 additions & 7 deletions Exception/InvalidMessageTypeException.php

This file was deleted.

Loading