Skip to content

Commit a8e059c

Browse files
authored
Merge pull request #1047 from OneSignal/fg/cordova-types
Add cordova types package
2 parents a3790f6 + 3250532 commit a8e059c

17 files changed

+1765
-1273
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules
22
dist
3+
4+
.vscode

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": false,
3+
"trailingComma": "all"
4+
}

example/IonicCapOneSignal/src/OSDemo.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class OSDemo extends React.Component<Props, State> {
6262
// Call to display the notification after 5 second delay
6363
notif.display();
6464
}, 10000);
65-
}
65+
},
6666
);
6767

6868
OneSignal.Notifications.addEventListener("click", (event) => {
@@ -93,7 +93,7 @@ class OSDemo extends React.Component<Props, State> {
9393
"change",
9494
(subscription) => {
9595
this.OSLog("OneSignal: subscription changed:", subscription);
96-
}
96+
},
9797
);
9898

9999
OneSignal.Notifications.addEventListener("permissionChange", (granted) => {
@@ -105,7 +105,7 @@ class OSDemo extends React.Component<Props, State> {
105105
});
106106
}
107107

108-
OSLog = (message: string, optionalArg: any = null) => {
108+
OSLog = (message: string, optionalArg: unknown = null) => {
109109
if (optionalArg !== null) {
110110
message = message + JSON.stringify(optionalArg);
111111
}

package-lock.json

Lines changed: 12 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,8 @@
6767
"bugs": {
6868
"url": "https://github.com/onesignal/OneSignal-Cordova-SDK/issues"
6969
},
70-
"homepage": "https://github.com/onesignal/OneSignal-Cordova-SDK#readme"
70+
"homepage": "https://github.com/onesignal/OneSignal-Cordova-SDK#readme",
71+
"devDependencies": {
72+
"@types/cordova": "^11.0.3"
73+
}
7174
}

tsconfig.json

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
{
2-
"compilerOptions": {
3-
"outDir": "dist",
4-
"target": "es5",
5-
"moduleResolution": "node",
6-
"noImplicitAny": true,
7-
"lib": [
8-
"es6",
9-
"dom",
10-
],
11-
"declaration": true,
12-
"allowSyntheticDefaultImports": true,
13-
"esModuleInterop": true,
14-
"strict": true,
15-
"noUnusedLocals": true,
16-
},
17-
"include": [
18-
"www"
19-
]
2+
"compilerOptions": {
3+
"outDir": "dist",
4+
"target": "es5",
5+
"moduleResolution": "node",
6+
"noImplicitAny": true,
7+
"lib": ["es6", "dom"],
8+
"declaration": true,
9+
"allowSyntheticDefaultImports": true,
10+
"esModuleInterop": true,
11+
"strict": true,
12+
"noUnusedLocals": true
13+
},
14+
"include": ["www"]
2015
}

www/DebugNamespace.ts

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,42 @@
1-
// Suppress TS warnings about window.cordova
2-
declare let window: any; // turn off type checking
3-
41
// An enum that declares different types of log levels you can use with the OneSignal SDK, going from the least verbose (none) to verbose (print all comments).
52
export enum LogLevel {
6-
None = 0,
7-
Fatal,
8-
Error,
9-
Warn,
10-
Info,
11-
Debug,
12-
Verbose,
3+
None = 0,
4+
Fatal,
5+
Error,
6+
Warn,
7+
Info,
8+
Debug,
9+
Verbose,
1310
}
1411

1512
export default class Debug {
16-
/**
17-
* Enable logging to help debug if you run into an issue setting up OneSignal.
18-
* @param {LogLevel} logLevel - Sets the logging level to print to the Android LogCat log or Xcode log.
19-
* @returns void
20-
*/
21-
setLogLevel(logLevel: LogLevel): void {
22-
window.cordova.exec(function(){}, function(){}, "OneSignalPush", "setLogLevel", [logLevel]);
23-
};
13+
/**
14+
* Enable logging to help debug if you run into an issue setting up OneSignal.
15+
* @param {LogLevel} logLevel - Sets the logging level to print to the Android LogCat log or Xcode log.
16+
* @returns void
17+
*/
18+
setLogLevel(logLevel: LogLevel): void {
19+
window.cordova.exec(
20+
function () {},
21+
function () {},
22+
"OneSignalPush",
23+
"setLogLevel",
24+
[logLevel],
25+
);
26+
}
2427

25-
/**
26-
* Enable logging to help debug if you run into an issue setting up OneSignal.
27-
* @param {LogLevel} visualLogLevel - Sets the logging level to show as alert dialogs.
28-
* @returns void
29-
*/
30-
setAlertLevel(visualLogLevel: LogLevel): void {
31-
window.cordova.exec(function(){}, function(){}, "OneSignalPush", "setAlertLevel", [visualLogLevel]);
32-
}
28+
/**
29+
* Enable logging to help debug if you run into an issue setting up OneSignal.
30+
* @param {LogLevel} visualLogLevel - Sets the logging level to show as alert dialogs.
31+
* @returns void
32+
*/
33+
setAlertLevel(visualLogLevel: LogLevel): void {
34+
window.cordova.exec(
35+
function () {},
36+
function () {},
37+
"OneSignalPush",
38+
"setAlertLevel",
39+
[visualLogLevel],
40+
);
41+
}
3342
}

0 commit comments

Comments
 (0)