Skip to content

update show doorbell feedback function calls for iOS and Android #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Doorbell.io plugin for nativescript
# Usage
```
import { showDoorbellFeedback } from 'nativescript-doorbell.io';
import { isIOS } from 'platform';
import { isIOS } from 'tns-core-modules/platform';

const viewController = isIOS ? this.feedbackContainer.nativeElement.ios.viewController : null;
showDoorbellFeedback(appId, appKey, viewController);
Expand Down
39 changes: 30 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
var application = require("application");
var platform = require("platform");
var application = require('application');
var platform = require('platform');

var exports = {};

if (platform.isAndroid) {
exports.showDoorbellFeedback = function(appId, appKey) {
const feedback = new io.doorbell.android.Doorbell(application.android.currentContext, parseInt(appId), appKey);
exports.showDoorbellFeedback = function(appId, appKey, properties = null) {
const feedback = new io.doorbell.android.Doorbell(
application.android.startActivity,
parseInt(appId),
appKey
);
if (properties) {
for (var p in properties) {
feedback.addProperty(p, properties[p]);
}
}
feedback.show();
}
};
} else {
exports.showDoorbellFeedback = function(appId, appKey, viewController, animated = true) {
exports.showDoorbellFeedback = function(
appId,
appKey,
viewController,
properties = null,
animated = true
) {
const feedback = Doorbell.alloc().initWithApiKeyAppId(appKey, appId);
feedback.showFeedbackDialogInViewControllerCompletionAnimated(viewController, (error) => {}, animated);
}
feedback.animated = animated;
if (properties) {
for (var p in properties) {
feedback.addPropertyWithNameAndValue(p, properties[p]);
}
}
feedback.showFeedbackDialogInViewControllerCompletion(viewController, error => {});
};
}

module.exports = exports;
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "nativescript-doorbell.io",
"version": "0.0.3",
"version": "0.0.5",
"nativescript": {
"platforms": {
"ios": "1.3.0",
"android": "1.2.0"
}
}
}
}