https://github.com/smartface/sf-plugin-netmera
https://github.com/smartface/sf-plugin-netmera
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/smartface/sf-plugin-netmera
- Owner: smartface
- License: mit
- Created: 2021-03-22T11:04:22.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-03T15:04:47.000Z (about 5 years ago)
- Last Synced: 2025-02-01T20:30:14.288Z (over 1 year ago)
- Language: JavaScript
- Size: 59.6 KB
- Stars: 0
- Watchers: 10
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Netmera plugin from Smartface
[](https://twitter.com/smartface_io)
[](https://raw.githubusercontent.com/smartface/sf-extension-extendedlabel/master/LICENSE)
## Netmera plugin
As a plugin, this plugin only works when published. Will not perform any action with regular run-on-device scenarios.
Netmera is a mobile engagement, communication and campaigning tool that collects the data of all your users on all channels, segments and targets in real-time using these data, and sends notifications and pop-ups to the selected audience.
In order to use Netmera plugin, you must integrate this plugin to your existing Smartface project.
## Installation
Smartface Netmera plugin can be installed via npm easily from our public npm repository. The installation is pretty easy via Smartface Cloud IDE.
- Run command in terminal `(cd ~/workspace/scripts && npm i -S sf-plugin-netmera)`
## Configuration
Installation script automatically configures project.json. Please verify following records are in place.
Configuration is needed once only
### Android
***Building Android Plugin***
It is necessary to place a few files & modification in order to use netmera plugin. Follow the below steps;
**Step 1**
Download google-services.json from [Firebase console](https://console.firebase.google.com)
**Step 2**
- Place google-services.json file into `~/workspace/config/Android`
- This repository contains prepared android library project under `~/Native/android` directory.
- Finally, specify netmera plugin library to config/project.json.
```javascript
"plugins": {
"modules": {
"netmera": {
"path": "plugins/Android/netmera",
"active": true
}
}
},
```
**Step 3**
- Get senderID from firebase and edit `config/project.json`'s senderID ⇒ (senderID = gcm_defaultSenderId )
```json
"googleCloudMessaging": {
"senderID": "${senderID}"
}
```
**Step 4**
- Add this lines to `config/Android/AndroidManifest.xml` file.
```xml
...
```
NetmeraApplication is an class which is subclass of the Application. It's mandatory to define in `application` if you are using Netmera plugin.
**Step 5**
- Apply plugins & specify library project in dependencies.gradle which is located under `~/workspace/config/Android` folder. Such as;
```groovy
dependencies {
implementation(project(':netmera'))
}
apply plugin: 'com.google.gms.google-services'
```
- Congrats you have just done Android configuration.
*Note: By post-install scripts, netmera plugins will be placed to appropriate paths and specify the its configuration to `config/project.json`*
### API
For each module api documentation is in separate file. Please visit [doc](./doc) folder
## Initialize
- Initialize your SDK using the following code snippet: (You must write this code in app.ts)
Netmera has to be initialized before any use.
```typescript
import Netmera from 'sf-plugin-netmera';
import Notifications from "sf-plugin-netmera/notification";
Netmera.apiKey = '***********';
Netmera.popupPresentationEnabled = true;
Notifications.onPushReceive = (e) =>{
alert("Receive ", e);
}
Notifications.onPushDismiss = (e) => {
alert("dimiss " , e);
}
Notifications.onPushOpen = (e) => {
alert("open ", e);
}
Notifications.onPushRegister = (e) => {
alert("register ", e);
}
Notifications.onPushButtonClicked = (e) => {
alert("clicked ", e);
}
```
Notification events are have some restrictions while the app in background state; onPushButtonClicked & onPushOpen will be called if the action make the application run and other events won't trigger.
### Sample Page for Netmera
```typescript
import Page1Design from 'generated/pages/page1';
import componentContextPatch from "@smartface/contx/lib/smartface/componentContextPatch";
import PageTitleLayout from "components/PageTitleLayout";
import System from "sf-core/device/system";
import Netmera from "sf-plugin-netmera";
export default class Page1 extends Page1Design {
router: any;
constructor () {
super();
// Overrides super.onShow method
this.onShow = onShow.bind(this, this.onShow.bind(this));
// Overrides super.onLoad method
this.onLoad = onLoad.bind(this, this.onLoad.bind(this));
this.btnNext.onPress = () => {
this.router.push("/pages/page2", { message: "Hello World!" });
}
}
}
/**
* @event onShow
* This event is called when a page appears on the screen (everytime).
*/
function onShow(superOnShow: () => void) {
superOnShow();
this.headerBar.titleLayout.applyLayout();
Netmera.requestPermissionsForLocation();
Netmera.loggingEnabled = true;
}
/**
* @event onLoad
* This event is called once when page is created.
*/
function onLoad(superOnLoad: () => void) {
superOnLoad();
this.headerBar.leftItemEnabled = false;
this.headerBar.titleLayout = new PageTitleLayout();
componentContextPatch(this.headerBar.titleLayout, "titleLayout");
if (System.OS === "Android") {
this.headerBar.title = "";
}
}
```
# License
This project is licensed under the terms of the MIT license. See the [LICENSE](https://raw.githubusercontent.com/smartface/sf-extension-extendedlabel/master/LICENSE) file. Within the scope of this license, all modifications to the source code, regardless of the fact that it is used commercially or not, shall be committed as a contribution back to this repository.