我正在尝试使用FCM将推送通知发送到iOS上的主题 . 我能够通过FCM控制台成功发送,下面的PHP脚本发送到Android的主题 .

这就是我正在使用的:

<?php
    $msg = array
    (
    'body'      => 'IOS TEST',
    'title'     => 'IOS TEST',
    'icon'      => 'new',
    'vibrate'   => 1,
    'sound'     => 1
    );

    $fields = array
    (
        'to'            => '/topics/channel',
        'notification'  => $msg
    );

    $headers = array
    (
        "Authorization: key = xxxxxxxxxxxxxxxxxxxxxx_w",
        "Content-Type: application/json"
    );
    print_r($headers);
    $ch = curl_init();
    curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
    curl_setopt( $ch,CURLOPT_POST, true );
    curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
    curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
    curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
    $result = curl_exec($ch );
    curl_close( $ch );
    echo $result;
?>

上面的PHP代码适用于Android但不适用于iOS,并且还返回一个message_id,表明它已被正确处理 .

这是我按照此处的说明添加到我的Xcodes 'ViewController.m'文件https://firebase.google.com/docs/cloud-messaging/ios/topic-messaging

- (IBAction)handleSubscribeTouch:(id)sender {
    // [START subscribe_topic]
    [[FIRMessaging messaging] subscribeToTopic:@"channel"];
    NSLog(@"Subscribed to news topic");
    // [END subscribe_topic]
}

在调试器区域,我没有看到有关主题订阅的任何通信,因此,鉴于我的症状,我怀疑Xcode方面的问题比我正在使用的PHP脚本更多 .

只是为了确认,我可以在从FCM控制台发送时正确接收iOS消息 .

我可能做错的任何指示都会很棒,谢谢 .