How to use the appcenter-push.setListener function in appcenter-push

To help you get started, we’ve selected a few appcenter-push examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github syun0216 / goforeat / index.js View on Github external
import { AppRegistry,AppState,Alert } from 'react-native';
import App from './App';
import Push from 'appcenter-push';


AppRegistry.registerComponent('goforeat_app', () => App);

Push.setListener({
	onPushNotificationReceived: pushNotification => {
    console.log(112312321321312321);
		let message = pushNotification.message;
		let title = pushNotification.title;
		let customProperties = [];
		let timestamp = Date.now();

		// Custom name/value pairs set in the App Center web portal are in customProperties
		if (
			pushNotification.customProperties &&
			Object.keys(pushNotification.customProperties).length > 0
		) {
			customProperties = pushNotification.customProperties;
		}

		Alert.alert(title, message);
github microsoft / appcenter-sdk-react-native / TestApp34 / MainScreen.js View on Github external
return (
      
    );
  }
}

Push.setListener({
  onPushNotificationReceived(pushNotification) {
    let message = pushNotification.message;
    let title = pushNotification.title;

    if (message === null || message === undefined) {
      // Android messages received in the background don't include a message. On Android, that fact can be used to
      // check if the message was received in the background or foreground. For iOS the message is always present.
      title = 'Android background';
      message = '';
    }

    // Any custom name/value pairs added in the portal are in customProperties
    if (pushNotification.customProperties && Object.keys(pushNotification.customProperties).length > 0) {
      message += `\nCustom properties:\n${JSON.stringify(pushNotification.customProperties)}`;
    }
github microsoft / appcenter-sdk-react-native / TestApp / app / App.js View on Github external
AppCenter: AppCenterScreen,
    Analytics: AnalyticsScreen,
    Transmission: TransmissionScreen,
    Crashes: CrashesScreen
  },
  {
    tabBarOptions: {
      activeBackgroundColor: 'white',
      inactiveBackgroundColor: 'white',
    },
  }
);

export default createAppContainer(TabNavigator);

Push.setListener({
  onPushNotificationReceived(pushNotification) {
    let message = pushNotification.message;
    const title = pushNotification.title;

    // Message can be null on iOS silent push or Android background notifications.
    if (message === null) {
      message = '';
    } else {
      message += '\n';
    }

    // Any custom name/value pairs added in the portal are in customProperties
    if (pushNotification.customProperties && Object.keys(pushNotification.customProperties).length > 0) {
      message += `Custom properties:\n${JSON.stringify(pushNotification.customProperties)}`;
    }
github microsoft / appcenter-sdk-react-native / DemoApp / app / App.js View on Github external
Analytics: AnalyticsScreen,
    Transmission: TransmissionScreen,
    Crashes: CrashesScreen,
    Data: DataScreen
  },
  {
    tabBarOptions: {
      activeBackgroundColor: 'white',
      inactiveBackgroundColor: 'white',
    },
  }
);

export default createAppContainer(TabNavigator);

Push.setListener({
  onPushNotificationReceived(pushNotification) {
    let message = pushNotification.message;
    const title = pushNotification.title;

    // Message can be null on iOS silent push or Android background notifications.
    if (message === null) {
      message = '';
    } else {
      message += '\n';
    }

    // Any custom name/value pairs added in the portal are in customProperties
    if (pushNotification.customProperties && Object.keys(pushNotification.customProperties).length > 0) {
      message += `Custom properties:\n${JSON.stringify(pushNotification.customProperties)}`;
    }
github microsoft / appcenter-sdk-react-native / TestAppTypescript / src / MainScreen.tsx View on Github external
<button title="Test Crashes"> navigate("Crashes")} /&gt;
        </button><button title="Test Analytics"> navigate("Analytics")} /&gt;
        </button><button title="Test Push"> navigate("Push")} /&gt;
        </button><button title="Test Other AppCenter APIs"> navigate("AppCenter")}
        /&gt;
      
    );
  }
}

Push.setListener({
  onPushNotificationReceived(pushNotification) {
    let message = pushNotification.message;
    let title = pushNotification.title;
    if (title === null) {
      title = "";
    }

    if (message === null) {
      message = "";
    } else {
      message += "\n";
    }

    // Any custom name/value pairs added in the portal are in customProperties
    if (
      pushNotification.customProperties &amp;&amp;</button>
github esteemapp / esteem-mobile / src / screens / application / container / applicationContainer.js View on Github external
_createPushListener = () => {
    const { dispatch } = this.props;
    let params = null;
    let key = null;
    let routeName = null;

    Push.setListener({
      onPushNotificationReceived(pushNotification) {
        if (previousAppState !== 'active') {
          const push = get(pushNotification, 'customProperties');
          const type = get(push, 'type', '');
          const permlink1 = get(push, 'permlink1', '');
          const permlink2 = get(push, 'permlink2', '');
          const permlink3 = get(push, 'permlink3', '');
          //const parentPermlink1 = get(push, 'parent_permlink1', '');
          //const parentPermlink2 = get(push, 'parent_permlink2', '');
          //const parentPermlink3 = get(push, 'parent_permlink3', '');

          //const fullParentPermlink = `${parentPermlink1}${parentPermlink2}${parentPermlink3}`;
          const fullPermlink = `${permlink1}${permlink2}${permlink3}`;

          const username = get(push, 'target', '');
          const activity_id = get(push, 'id', '');

appcenter-push

React Native plugin for AppCenter Push

MIT
Latest version published 4 years ago

Package Health Score

50 / 100
Full package analysis