edamov / pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key)
MIT License
378 stars 120 forks source link

The `Alert` option is set in the code but there is no Alert on the phone #155

Open wangershuai opened 2 years ago

wangershuai commented 2 years ago

With this setup, the card data in the phone changes, but there is no pop-up notification

  $options = [
                'key_id' => env('APPLE_KEY_ID'), // The Key ID obtained from Apple developer account
                'team_id' => env("APPLE_TEAM_ID"), // The Team ID obtained from Apple developer account
                'app_bundle_id' => env("PASS_TYPE_ID"), // The bundle ID for app obtained from Apple developer account
                'private_key_path' => base_path() . env("APPLE_APPLICATION_CREDENTIALS_P8"), // Path to private key
                'private_key_secret' => null // Private key secret
            ];

            $authProvider = AuthProvider\Token::create($options);

            $alert = Alert::create()->setTitle('Hello!');
            $alert = $alert->setBody('First push notification');

            $payload = Payload::create()->setAlert($alert);
            $payload->setSound('default');
            $payload = $payload->setCustomValue("balance", "new");

            // 更新的组
            $deviceTokens = [];
            $deviceTokens[] = $sPushToken;

            $notifications = [];
            foreach ($deviceTokens as $deviceToken) {
                $notifications[] = new Notification($payload, $deviceToken);
            }

            $client = new Client($authProvider, $production = true);
            $client->addNotifications($notifications);

            $responses = $client->push();
Bekshakx commented 2 days ago

@wangershuai have you solved this problem?