推送通知在使用Azure Pipeline创建的iOS版本中不起作用

unguejic  于 2022-11-26  发布在  iOS
关注(0)|答案(2)|浏览(196)

在Xamarin.forms项目中,我尝试使用下面的YML脚本创建构建。我添加了安装Appstore分发和APNS证书.p12文件的任务。整个脚本工作正常,构建工作正常,只有推送通知不工作,下面是我使用的脚本:

stage: iOSBuildProd
  displayName: iOS Build Prod
  dependsOn: iOSBuildQA
  pool:
      vmImage: 'macOS-latest'
  jobs:
    - job: iOSBuildSolution
      displayName: iOS Build Solution
      steps:
      - script: sudo $AGENT_HOMEDIRECTORY/scripts/select-xamarin-sdk.sh 5_0_0 
        displayName: 'Select Xamarin SDK version'
        enabled: false
      - task: InstallAppleCertificate@2
        displayName: installing Build certificate
        inputs:
          certSecureFile: '$(certAPNSFile)'
          certPwd: '$(certificatePassword)'
          keychain: 'temp'
          deleteCert: true  
      - task: InstallAppleCertificate@2
        displayName: installing Build certificate
        inputs:
          certSecureFile: '$(certDistributionFile)'
          certPwd: '$(certificatePassword)'
          keychain: 'temp'
          deleteCert: true  

      - task: InstallAppleProvisioningProfile@1
        displayName: installing provisioning profiles
        inputs:
          provisioningProfileLocation: 'secureFiles'
          provProfileSecureFile: $(AppStoreProfileName)
          removeProfile: true
      - task: NuGetToolInstaller@1
        displayName: 'NuGet Installer'
      - task: NuGetCommand@2
        displayName: 'NuGet Command'
        inputs:
          restoreSolution: '$(solutionPath)'
      - task: XamariniOS@2
        displayName: 'iOS Build'
        inputs:
          solutionFile: '$(iOSSolutionPath)'
          configuration: '$(solutionConfiguration)'
          args: '/p:IpaPackageDir="$(outputDirectory)"'
          packageApp: true
          buildForSimulator: false
          runNugetRestore: true
          signingIdentity: '$(APPLE_CERTIFICATE_SIGNING_IDENTITY)'
          signingProvisioningProfileID: '$(APPLE_PROV_PROFILE_UUID)'
      - task: PublishBuildArtifacts@1
        inputs:
          pathtoPublish: '$(outputDirectory)'
          ArtifactName: 'prodStage'
r1zhe5dt

r1zhe5dt1#

我是这样做的。这是行不通的,但我想分享一些代码。

- task: InstallAppleCertificate@2
  inputs:
    certSecureFile: 'apple_dev_2022.p12' 
    certPwd: $(iOSCertPassword)
    keychain: 'custom' # Options: default, temp, custom
    customKeychainPath: $(Agent.BuildDirectory)/CustomFirstKeyChain.keychain
    deleteCustomKeychain: true
    keychainPassword: $(iOSCertPassword)
  displayName: Install Development Certificate (Dev not Ad Hoc)
      
- task: InstallAppleCertificate@2
  inputs:
    certSecureFile: 'apple_dev_push_2022.p12' 
    certPwd: $(iOSCertPassword)
    keychain: 'custom' # Options: default, temp, custom
    customKeychainPath: $(Agent.BuildDirectory)/CustomSecondKeyChain.keychain
    deleteCustomKeychain: true
    keychainPassword: $(iOSCertPassword)
  displayName: Install Push Notification Certificate

- task: InstallAppleProvisioningProfile@1
  inputs:
    provisioningProfileLocation: 'secureFiles'
    provProfileSecureFile: 'My_App_Dev_not_Ad_Hoc_3_v2.mobileprovision'
p8h8hvxi

p8h8hvxi2#

我最终使用Firebase.plugin for .Net Maui来解决这个问题。我不知道我发布的安装两个Apple Certificates的代码是否修复了它。我已经用我自己构建的APN服务器进行了测试,但仍然无法正常工作。因此,我使用Firebase来发送推送通知。
如果您在iOS上构建Firebase.plugin时遇到问题,请查看此问题。https://github.com/TobiasBuchholz/Plugin.Firebase/issues/51

相关问题