question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hello,

Please let me know how do i need to use the plugin on Ionic2, here’s my code :

import {Component} from ‘@angular/core’; import {Platform, ionicBootstrap} from ‘ionic-angular’; import {StatusBar, Push} from ‘ionic-native’; import {TabsPage} from ‘./pages/tabs/tabs’; import {HTTP_PROVIDERS} from ‘@angular/http’; import {CloudSettings, provideCloud} from ‘@ionic/cloud-angular’;

const cloudSettings: CloudSettings = { ‘core’: { ‘app_id’: ‘363e500b’ } };

@Component({ template: ‘<ion-nav [root]=“rootPage”></ion-nav>’, providers: [HTTP_PROVIDERS] }) export class MyApp {

private rootPage: any;

constructor(private platform: Platform) { this.rootPage = TabsPage;

platform.ready().then(() => {

  StatusBar.styleDefault();

  var push = Push.init({
    ios: {
      alert: "true",
      badge: true,
      sound: 'false'
    }
  });

  push.on('registration', (data) => {
    console.log(data.registrationId);
    alert(data.registrationId.toString());
  });

  push.on('notification', (data) => {
    console.log(data);
    alert("Hi, Am a push notification");
  });

  push.on('error', (e) => {
    console.log(e.message);
  });


});

} }

ionicBootstrap(MyApp, [provideCloud(cloudSettings)]);

Thanks

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

5reactions
mebiboucommented, Jun 6, 2017

For those struggling with this:

  1. In your tsconfig.json add:
"files": [
    "plugins/cordova-fabric-plugin/typings/cordova-fabric-plugin.d.ts"
  ]
  1. In app.module.ts declare a custom error handler:
class MyErrorHandler extends IonicErrorHandler {
  handleError(error) {
    super.handleError(error);

    // example for logging on Android
    fabric.Crashlytics.sendNonFatalCrash(error);
  }
}

And use this handler in the providers of the module:

providers: [
  {provide: ErrorHandler, useClass: MyErrorHandler}
  ...
]
1reaction
davidquoncommented, Nov 23, 2016

For installing Fabric.io: https://www.npmjs.com/package/cordova-fabric-plugin#install

Then I was able to test Fabric.io and Crashlytics using:

(<any>window).fabric.Crashlytics.addLog("about to send a non fatal crash for testing!");
(<any>window).fabric.Crashlytics.sendNonFatalCrash("Error message")

Related links that I found useful: http://stackoverflow.com/a/30740935/6930701 http://stackoverflow.com/a/13480754/6930701 http://stackoverflow.com/a/18475706/6930701

Ionic Info (although these specific versions may not be required):

$ ionic info

Your system information:

Cordova CLI: 6.4.0
Gulp version:  CLI version 3.9.1
Gulp local:   Local version 3.9.1
Ionic Framework Version: 2.0.0-beta.11
Ionic CLI Version: 2.0.0-beta.37
Ionic App Lib Version: 2.0.0-beta.20
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Mac OS X El Capitan
Node Version: v7.0.0
Xcode version: Xcode 8.1 Build version 8B62 

Lastly I only tested on Android so I’m not 💯 about any other platform.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ionic Fabric: Boost your protection - Boost your confidence
Ionic Fabric with Acteev Protect's patent-pending antimicrobial technology offers a permanent solution that guards against the growth of unwanted ...
Read more >
ionic-native/fabric - npm
Ionic Native - Native plugins for ionic apps. Latest version: 5.36.0, last published: a year ago. Start using @ionic-native/fabric in your ...
Read more >
Ionic Fabric - Kelly Wearstler
Ionic creates an illusion of movement and shape. The blended woven fabric has been quilted and embroidered to add dimension. The contrasting colors...
Read more >
Answers | Ionic Documentation
API for interacting with the Answers kit. https://docs.fabric.io/crashlytics/index.html · https://www.npmjs.com/package/cordova ...
Read more >
Ionic+ - Noble Biomaterials
Ionic+ ® antimicrobial technology offers performance advantages when solving today's textile challenges. This broad portfolio of yarn, fiber, fabric, and foam ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found