Why PubNub iOS push messages is not working?

81 Views Asked by At

Ive developed a .Net API that register a mobile device to a channel and sends a push notification on it.

The code is like this:

Register phone:

            _pubNub.AddPushNotificationsOnChannels()
                .PushType(PNPushType.APNS2)
                .Channels(new string[] {
                   device.ChannelId.ToString()
                })
                .DeviceId(device.DeviceId)
                .Topic(_settings.ApplicationBundle)
                .Environment(device.Enviroment)
                .Execute(new AddDevicePushChannel());

When execute, the response is 200 and no error where register. So, i will sent the notification to my app using this code:

            _pubNub.Publish()
            .Channel(message.ChannelId.ToString())
            .Message(new string[] {
                  message.Text
                })
            .Execute(new PushPublishMessageChannel());

And again, no errors and status code is 200 on response from pubnub

But notification never get APNs

With same sdk, I've checked that the device belongs to the channel and according the response is ok.

  • Ive already sent a push from APNs console to my deviceId and works fine.
  • Of course all the configurations for iOS notifications in pubnub is ok, even the *.p8

Any suggestions?

EDIT:

        Dictionary<string, object> apnsData = new Dictionary<string, object>
        {
            {
               "aps", new Dictionary<string, string>() {
                    {
                       "alert","Hello"
                    }
            }
            }
        };

        MobilePayload mobilePayload = new MobilePayload();
        mobilePayload.pn_apns = apnsData;

        _pubNub.Publish()
            .Channel(message.ChannelId.ToString())
            .Message(mobilePayload)
            .Execute(new PushPublishMessageChannel());
0

There are 0 best solutions below