Skip to content

Commit

Permalink
allow instance with missing or background activity #46
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Sep 27, 2019
1 parent c2bc5ba commit b65a352
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/nfc.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ export class Nfc implements NfcApi {
// The adapter must be started with the foreground activity.
// This allows to start it as soon as possible but only once.
const foregroundActivity = application.android.foregroundActivity;
this.nfcAdapter = android.nfc.NfcAdapter.getDefaultAdapter(foregroundActivity);
if (!this.started && this.nfcAdapter !== null && foregroundActivity !== null) {
this.nfcAdapter = android.nfc.NfcAdapter.getDefaultAdapter(application.android.context);
if (!this.started && this.nfcAdapter !== null && foregroundActivity) {
this.started = true;
this.nfcAdapter.enableForegroundDispatch(foregroundActivity, this.pendingIntent, this.intentFilters, this.techLists);
// handle any pending intent
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-nfc",
"version": "4.0.3",
"version": "4.0.4",
"description": "NFC plugin for your NativeScript app",
"main": "nfc",
"typings": "index.d.ts",
Expand Down

0 comments on commit b65a352

Please sign in to comment.