Push Notifications with Images - November 2024
AppFlow supports building Capacitor applications that contain extensions. A typical extension is to allow notifications that support images.
The only requirement for AppFlow to build an extension is that you add the provisioning profile for the extension to AppFlow along with the provisioning profile of your application. However, as you go through this process you may cause some problems in your project and the rest of this guide covers errors you may encounter and how to resolve them.
Coding for Notifications with Images
Push notifications with images require some additional setup particularly with iOS. Setting this up with XCode requires a Notification Service Extension to be added to the XCode project. These steps are detailed in this guide:
https://capacitorjs.com/docs/guides/push-notifications-firebase#images-in-push-notifications
After following the above guide, the following information contains additional notes related to getting Appflow to build the app.
Important: In your XCode project make sure the notification extension is a group (right click and choose “Convert to Group”) otherwise you will get the “PBXGroup” detailed below in troubleshooting.
Appflow Setup
As your project has an additional profile for the notification extension you will need to add both the provisioning profile for your app and the notification extension to AppFlow (docs).
Troubleshooting Cocoapods
Push notifications in a Capacitor application (using the @capacitor/push-notifications plugin) have a common dependency of Firebasemessaging which is provided by Cocoapods. An Xcode project has a Podfile and Podfile.lock which specify the Cocoa Pod packages associated with your Xcode project. These are usually automatically updated by Capacitor when the sync command is run. But, as you are altering your XCode project manually you may need to know how to run a few commands related to CocoaPods:
Install / Upgrade Cocoapods
You will need to occasionally update or install Cocoapods to either match versions with other developers in your team, or to match the version installed on your CI/CD server. For AppFlow this version can be found in this document:
https://ionic.io/docs/appflow/build-stacks
At the time of writing the latest build stack is using Cocoapods version 1.15.2 by default.
It is a good idea to make sure you are using at least the version mentioned in the build stack documentation, but you can choose to use a different version, as when AppFlow builds your project it will install the version that is mentioned in the Podfile.lock file of your project.
To install the latest version of Cocoapods you can run the following command:
sudo gem install cocoapods
(There is additional information about installation of Cocoapods here).
Pod Install
Your Podfile in your XCode project is the equivalent of your package.json in your web project - it contains the list of dependencies. Also, the Podfile.lock is like your package-lock.json in that it specifies the exact versions that will be installed.
Running pod install in the terminal (in the ios/App folder) will install the dependencies. Running pod update will find updated versions of the dependencies. Also, deleting Podfile.lock and running pod install may be needed if you need to upgrade your dependencies to the latest.
You may need to use one of these techniques to ensure you are using the latest versions of dependencies as sometimes these dependencies must be updated based on requirements from Apple (for example related to privacy manifests).
PBXGroup Error
You may get the following error when your project builds:
`PBXGroup` attempted to initialize an object with unknown ISA `PBXFileSystemSynchronizedRootGroup` from attributes: `{"isa"=>"PBXFileSystemSynchronizedRootGroup", "exceptions"=>["2D0114492CEBB8270006D59F"], "explicitFileTypes"=>{}, "explicitFolders"=>[], "path"=>"pushextension", "sourceTree"=>"<group>"}`
If this ISA was generated by Xcode please file an issue: https://github.com/CocoaPods/Xcodeproj/issues/new
This is caused by your XCode project being malformed when you created your notification extension. It can be fixed in XCode by right clicking your extension and choosing Convert To Group:
Note: If you only see the menu option of “Convert to Folder” (and folder is gray and not blue) then it already a group.
No Profiles Error
error: No profiles for 'your.bundle.id.pushextension' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'your.bundle.id.pushextension'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild. (in target 'pushextension' from project 'App')
This indicates that you have not added the provisioning profile for the push extension. It needs to downloaded from the Apple Developer portal and uploaded to AppFlow.
Version 70 Error
CocoaPods Error: Unable to find compatibility version string for object version '70'
This is caused by Xcode 16.1 when you add the notification extension file to your project. The problem is in your XCode project.pbxproj file. Open this file and change objectVersion from 70 to 60.
Comments
0 comments
Article is closed for comments.