Implementation
If you've completed the steps described in the setup guides, you are now ready to implement our Flutter plugin package for iOS in your app. Our library supports iOS 9 and up. Make sure you always have the latest Xcode installed in your development machine.
To start please make sure you have followed the Getting started with Flutter tutorial. Once you have met all the requirements and you have prepared your machine for Flutter development you can then start implementing our plugin.
Install the Plugin Package
Assuming that you've already create a Flutter app, open pubspec.yaml, and add our plugin as a dependency:
dependencies:
flutter:
sdk: flutter
notificare_push_lib: ^2.3.0 // make sure you always use the latest library
Then in your terminal, run the following command:
flutter pub get
Or click Packages get in IntelliJ's Android Studio.
Configure your App
You will need to add some files included in our native library. For that, please download our latest release here. Unzip the downloaded file and open the resulting folder, then drag and drop Notificare.plist into your Xcode project:
Before you continue, you need to make sure you disable the AppDelegate proxying in Notificare, which is not supported in Flutter. For that simply open the Notificare.plist file you just dragged into your project and add the boolean property DISABLE_APP_DELEGATE_PROXY set to YES:
It is recommended that you create at least two different apps in Notificare using separated environments for development and production. For each app you will have a different set of keys, these keys should be copied and pasted in the file shown above. The DEVELOPMENT property should be set to YES or NO according to the environment you are building for. You can find your app keys by expanding your app's Settings menu item and clicking in App Keys as shown below:
Copy both the Application Key and Application Secret:
And paste them accordingly in the Notificare.plist file:
Entitlements
Before you can start implementing our plugin, you will need to add all the capabilities to your project in Xcode. Go to your app's target and click in the tab Capabilities:
Obviously, if you going to send push notifications, you will need to add Push Notifications by turning the following capability ON:
You should also turn the Remote Notifications background mode ON:
If you've subscribed to the Loyalty add-on and you will handle digital cards, then you should turn the Wallet capability ON:
If you've subscribed to the Monetize add-on and you will sell digital products in your app, then you should turn the In-App Purchase capability ON:
If you've subscribed to the Users & Authentication add-on and you will implement OAuth2 features in your app, then you should turn the Keychain Sharing capability ON:
If you are going to implement the NFC Reader capabilities of our library, you must turn the Near Field Communication Tag Reading capability ON:
Implementation
You are now ready to start implementing the native code necessary to make our module work. Open the file lib/main.dart and import our plugin as shown below:
import 'package:notificare_push_lib/notificare_push_lib.dart';
Then start by creating a reference to our plugin:
class _MyAppState extends State<MyApp> {
final NotificarePushLib notificare = NotificarePushLib();
...more code
}
Now the best way to initialize Notificare is to add the following to the initState method in your app's class:
..more code
class _MyAppState extends State<MyApp> {
final NotificarePushLib notificare = NotificarePushLib();
void initState() {
super.initState();
notificare.launch();
notificare.onEventReceived.listen((NotificareEvent event) {
if (event.name == "ready") {
}
});
... more code
}
}
At this point, you have completed the basic setup of our plugin. Keep reading our implementation guides to dive deeper into each features available in our SDK.