p8 certificate for remote messaging (azure notifications hub) problems?

Leonard Harris 6 Reputation points

Running into an problems setting up remote messaging:

We have followed this guide: https://learn.microsoft.com/en-us/azure/notification-hubs/xamarin-notification-hubs-ios-push-notification-apns-get-started which includes setting up a .p8 certificates on the apple from token-based authentication, benefits include they do not expire as opposed to the traditional .p12 push certificates. We have upload the .p8 file on azure notifications hub and when debugging the app remote notifications works perfectly.

The problem is trying to build and deploy an Adhoc or AppStore build is giving us an some problems, firstly we cannot deploy the app as its giving us a MT1006 error that is when we include the following in the entitlements. as we normally would do with a .p12 certificate setup





But when we remove the above from entitlements, the app builds & deploys fine for Adhoc or AppStore builds but we cannot get any notifications received and some tracing uncovered the following:

public override void FailedToRegisterForRemoteNotifications(

            UIApplication application,

            NSError error)



            Trace.WriteLine($"APP_REMOTE_FAILED: {error}");


From device log:

Time	Device Name	Type	PID	Tag	Message

Aug 30 13:56:05	Test-iPhone	Notice	1985	SampleAPP.iOS	APP_REMOTE_FAILED: no valid \M-b\M^@\M^\aps-environment\M-b\M^@\M^] entitlement string found for application

We understand the problem entitlement string not found error but when we try to add it we cannot build and deploy which I assume (correct me if wrong) is because we are using the token-based authentication with the .p8 file as created per below.


I would be interested to know if this option is supported and if so is there some additional configuration required, this is the first app we are trying with the token-based authentication and also first time we are having this issue and assume the two might be related.

Azure Notification Hubs
Azure Notification Hubs
An Azure service that is used to send push notifications to all major platforms from the cloud or on-premises environments.
270 questions
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,299 questions
Microsoft Intune iOS
Microsoft Intune iOS
Microsoft Intune: A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.iOS: An Apple mobile operating system.
190 questions
{count} votes

1 answer

Sort by: Most helpful
  1. brtrach-MSFT 15,351 Reputation points Microsoft Employee

    @Leonard Harris It seems like you are having trouble setting up remote messaging with Azure Notification Hubs using a .p8 certificate for token-based authentication. According to the documentation, you can use a .p8 certificate for token-based authentication instead of a traditional .p12 push certificate. However, you are encountering an error when trying to deploy the app with the entitlements key "aps-environment" set to "production".

    The error message you are seeing indicates that there is no valid "aps-environment" entitlement string found for the application. This is because you are using token-based authentication with a .p8 file, which does not require the "aps-environment" entitlement key.

    It seems that you were able to get remote messaging working on iOS for AppStore build by including the "aps-environment" entitlement key with the value "production". However, this is not working for Adhoc build.

    Based on the documentation, it seems that you should not include the "aps-environment" entitlement key when using token-based authentication with a .p8 file. Instead, you should use the following steps to configure your notification hub with APNS information:

    1. In the Azure portal, on the Notification Hub page, select Apple (APNS) on the left menu.
    2. For Authentication Mode, select Token.
    3. Enter the values for Key ID, Bundle ID, Team ID, and Token.
    4. Select Sandbox mode. Or, to send push notifications to users who purchased your app from the store, select Production mode.