Skip to content

Commit 79bce99

Browse files
authored
Merge pull request #4 from OneSignal/package_name
Package name
2 parents d3f3cdc + 1864dca commit 79bce99

19 files changed

+79
-106
lines changed

android/src/main/java/com/onesignal/flutter/OneSignalPlugin.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ private void didSetNotificationOpenedHandler() {
252252

253253
@Override
254254
public void onOSSubscriptionChanged(OSSubscriptionStateChanges stateChanges) {
255-
Log.d("onesignal", "Subscription changed calling observer");
256255
this.channel.invokeMethod("OneSignal#subscriptionChanged", OneSignalSerializer.convertSubscriptionStateChangesToMap(stateChanges));
257256
}
258257

@@ -281,8 +280,7 @@ public void notificationOpened(OSNotificationOpenResult result) {
281280
this.coldStartNotificationResult = result;
282281
return;
283282
}
284-
285-
Log.d("onesignal", "OS Notification Opened");
283+
286284
try {
287285
this.channel.invokeMethod("OneSignal#handleOpenedNotification", OneSignalSerializer.convertNotificationOpenResultToMap(result));
288286
} catch (JSONException exception) {

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
22
import 'dart:async';
33

44
//import OneSignal
5-
import 'package:OneSignalFlutter/onesignal.dart';
5+
import 'package:onesignal/onesignal.dart';
66

77
void main() => runApp(new MyApp());
88

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dev_dependencies:
1616
sdk: flutter
1717

1818

19-
OneSignalFlutter:
19+
onesignal:
2020
path: ../
2121

2222
# For information on the generic Dart part of this file, see the

example/test/widget_test.dart

Lines changed: 0 additions & 25 deletions
This file was deleted.

ios/Classes/OneSignalTagsController.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131

3232
@implementation OneSignalTagsController
3333
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
34-
NSLog(@"Registering tags controller");
35-
3634
OneSignalTagsController *instance = [OneSignalTagsController new];
3735

3836
instance.channel = [FlutterMethodChannel

ios/OneSignalFlutter.podspec renamed to ios/onesignal.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
33
#
44
Pod::Spec.new do |s|
5-
s.name = 'OneSignalFlutter'
5+
s.name = 'onesignal'
66
s.version = '0.0.1'
77
s.summary = 'The OneSignal Flutter SDK'
88
s.description = 'Allows you to easily add OneSignal to your flutter projects, to make sending and handling push notifications easy'

lib/onesignal.dart

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import 'dart:async';
22
import 'package:flutter/services.dart';
3-
import 'package:OneSignalFlutter/src/permission.dart';
4-
import 'package:OneSignalFlutter/src/subscription.dart';
5-
import 'package:OneSignalFlutter/src/defines.dart';
6-
import 'package:OneSignalFlutter/src/utils.dart';
7-
import 'package:OneSignalFlutter/src/notification.dart';
8-
import 'package:OneSignalFlutter/src/create_notification.dart';
3+
import 'package:onesignal/src/permission.dart';
4+
import 'package:onesignal/src/subscription.dart';
5+
import 'package:onesignal/src/defines.dart';
6+
import 'package:onesignal/src/utils.dart';
7+
import 'package:onesignal/src/notification.dart';
8+
import 'package:onesignal/src/create_notification.dart';
99

1010
export 'src/notification.dart';
1111
export 'src/subscription.dart';
@@ -160,7 +160,7 @@ class OneSignal {
160160
/// This method can often take more than five seconds to complete,
161161
/// so please do NOT block any user-interactive content while
162162
/// waiting for this request to complete.
163-
Future<Map<String, dynamic>> sendTag(dynamic key, dynamic value) async {
163+
Future<Map<String, dynamic>> sendTag(String key, dynamic value) async {
164164
Map<dynamic, dynamic> response = await this.sendTags({ key : value });
165165
return response.cast<String, dynamic>();
166166
}
@@ -169,7 +169,7 @@ class OneSignal {
169169
/// This method can often take more than five seconds to complete,
170170
/// so please do NOT block any user-interactive content while
171171
/// waiting for this request to complete.
172-
Future<Map<String, dynamic>> sendTags(Map<dynamic, dynamic> tags) async {
172+
Future<Map<String, dynamic>> sendTags(Map<String, dynamic> tags) async {
173173
Map<dynamic, dynamic> response = await _tagsChannel.invokeMethod("OneSignal#sendTags", tags);
174174
return response.cast<String, dynamic>();
175175
}
@@ -207,25 +207,27 @@ class OneSignal {
207207
Future<OSPermissionSubscriptionState> getPermissionSubscriptionState() async {
208208
var json = await _channel.invokeMethod("OneSignal#getPermissionSubscriptionState");
209209

210-
return OSPermissionSubscriptionState(json);
210+
return OSPermissionSubscriptionState(json.cast<String, dynamic>());
211211
}
212212

213213
/// Allows you to manually disable or enable push notifications for this user.
214214
/// Note: This method does not change the user's system (iOS) push notification
215215
/// permission status. If the user disabled (or never allowed) your application
216216
/// to send push notifications, calling setSubscription(true) will not change that.
217217
Future<void> setSubscription(bool enable) async {
218-
await _channel.invokeMethod("OneSignal#setSubscription", enable);
218+
return await _channel.invokeMethod("OneSignal#setSubscription", enable);
219219
}
220220

221221
/// Allows you to post a notification to the current user (or a different user
222222
/// if you specify their OneSignal user ID).
223-
Future<Map<dynamic, dynamic>> postNotificationWithJson(Map<dynamic, dynamic> json) async {
224-
return await _channel.invokeMethod("OneSignal#postNotification", json);
223+
Future<Map<String, dynamic>> postNotificationWithJson(Map<String, dynamic> json) async {
224+
Map<dynamic, dynamic> response = await _channel.invokeMethod("OneSignal#postNotification", json);
225+
return response.cast<String, dynamic>();
225226
}
226227

227-
Future<Map<dynamic, dynamic>> postNotification(OSCreateNotification notification) async {
228-
return await _channel.invokeMethod("OneSignal#postNotification", notification.mapRepresentation());
228+
Future<Map<String, dynamic>> postNotification(OSCreateNotification notification) async {
229+
Map<dynamic, dynamic> response = await _channel.invokeMethod("OneSignal#postNotification", notification.mapRepresentation());
230+
return response.cast<String, dynamic>();
229231
}
230232

231233
/// Allows you to prompt the user for permission to use location services
@@ -260,15 +262,15 @@ class OneSignal {
260262
// Private function that gets called by ObjC/Java
261263
Future<Null> _handleMethod(MethodCall call) async {
262264
if (call.method == 'OneSignal#handleReceivedNotification' && this._onReceivedNotification != null) {
263-
return this._onReceivedNotification(OSNotification(call.arguments as Map<dynamic, dynamic>));
265+
return this._onReceivedNotification(OSNotification(call.arguments.cast<String, dynamic>()));
264266
} else if (call.method == 'OneSignal#handleOpenedNotification' && this._onOpenedNotification != null) {
265-
return this._onOpenedNotification(OSNotificationOpenedResult(call.arguments as Map<dynamic, dynamic>));
267+
return this._onOpenedNotification(OSNotificationOpenedResult(call.arguments.cast<String, dynamic>()));
266268
} else if (call.method == 'OneSignal#subscriptionChanged' && this._onSubscriptionChangedHandler != null) {
267-
return this._onSubscriptionChangedHandler(OSSubscriptionStateChanges(call.arguments as Map<dynamic, dynamic>));
269+
return this._onSubscriptionChangedHandler(OSSubscriptionStateChanges(call.arguments.cast<String, dynamic>()));
268270
} else if (call.method == 'OneSignal#permissionChanged' && this._onPermissionChangedHandler != null) {
269-
return this._onPermissionChangedHandler(OSPermissionStateChanges(call.arguments as Map<dynamic, dynamic>));
271+
return this._onPermissionChangedHandler(OSPermissionStateChanges(call.arguments.cast<String, dynamic>()));
270272
} else if (call.method == 'OneSignal#emailSubscriptionChanged' && this._onEmailSubscriptionChangedHandler != null) {
271-
return this._onEmailSubscriptionChangedHandler(OSEmailSubscriptionStateChanges(call.arguments as Map<dynamic, dynamic>));
273+
return this._onEmailSubscriptionChangedHandler(OSEmailSubscriptionStateChanges(call.arguments.cast<String, dynamic>()));
272274
}
273275

274276
return null;

lib/src/create_notification.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import 'package:OneSignalFlutter/src/utils.dart';
1+
import 'package:onesignal/src/utils.dart';
22
import 'package:flutter/foundation.dart';
3-
import 'package:OneSignalFlutter/src/notification.dart';
4-
import 'package:OneSignalFlutter/onesignal.dart';
3+
import 'package:onesignal/src/notification.dart';
4+
import 'package:onesignal/onesignal.dart';
55

66
/// The parameters & format to create push notifications is
77
/// so different from receiving notifications that we represent

lib/src/notification.dart

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import 'package:OneSignalFlutter/src/defines.dart';
2-
import 'package:OneSignalFlutter/src/utils.dart';
1+
import 'package:onesignal/src/defines.dart';
2+
import 'package:onesignal/src/utils.dart';
33
import 'package:flutter/foundation.dart';
44
import 'dart:convert';
55

@@ -36,8 +36,8 @@ class OSNotification extends JSONStringRepresentable {
3636
int androidNotificationId;
3737

3838
//converts JSON map to OSNotification instance
39-
OSNotification(Map<dynamic, dynamic> json) {
40-
this.payload = OSNotificationPayload(json['payload'] as Map<dynamic, dynamic>);
39+
OSNotification(Map<String, dynamic> json) {
40+
this.payload = OSNotificationPayload(json['payload'].cast<String, dynamic>());
4141
this.shown = json['shown'] as bool;
4242
this.appInFocus = json['appInFocus'] as bool;
4343
this.silent = json['silent'] as bool;
@@ -121,11 +121,11 @@ class OSNotificationPayload extends JSONStringRepresentable {
121121

122122
/// Any additional custom data you want to send along
123123
/// with this notification.
124-
Map<dynamic, dynamic> additionalData;
124+
Map<String, dynamic> additionalData;
125125

126126
/// Any attachments (images, sounds, videos) you want
127127
/// to display with this notification.
128-
Map<dynamic, dynamic> attachments;
128+
Map<String, dynamic> attachments;
129129

130130
/// Any buttons you want to add to the notification.
131131
/// The notificationOpened handler will provide an
@@ -135,7 +135,7 @@ class OSNotificationPayload extends JSONStringRepresentable {
135135

136136
/// A hashmap object representing the raw key/value
137137
/// properties of the push notification
138-
dynamic rawPayload;
138+
Map<String, dynamic> rawPayload;
139139

140140
/// (Android Only)
141141
/// The filename of the image to use as the small
@@ -211,7 +211,7 @@ class OSNotificationPayload extends JSONStringRepresentable {
211211
/// notification (if set)
212212
OSAndroidBackgroundImageLayout backgroundImageLayout;
213213

214-
OSNotificationPayload(Map<dynamic, dynamic> json) {
214+
OSNotificationPayload(Map<String, dynamic> json) {
215215
this.notificationId = json['notificationId'] as String;
216216

217217
// iOS Specific Parameters
@@ -221,7 +221,7 @@ class OSNotificationPayload extends JSONStringRepresentable {
221221
if (json.containsKey('badge')) this.badge = json['badge'] as int;
222222
if (json.containsKey('badgeIncrement')) this.badgeIncrement = json['badgeIncrement'] as int;
223223
if (json.containsKey('subtitle')) this.subtitle = json['subtitle'] as String;
224-
if (json.containsKey('attachments')) this.attachments = json['attachments'] as Map<dynamic, dynamic>;
224+
if (json.containsKey('attachments')) this.attachments = json['attachments'].cast<String, dynamic>();
225225

226226
// Android Specific Parameters
227227
if (json.containsKey("smallIcon")) this.smallIcon = json['smallIcon'] as String;
@@ -242,10 +242,10 @@ class OSNotificationPayload extends JSONStringRepresentable {
242242
if (json.containsKey('title')) this.title = json['title'] as String;
243243
if (json.containsKey('body')) this.body = json['body'] as String;
244244
if (json.containsKey('launchUrl')) this.launchUrl = json['launchUrl'] as String;
245-
if (json.containsKey('additionalData')) this.additionalData = json['additionalData'] as Map<dynamic, dynamic>;
245+
if (json.containsKey('additionalData')) this.additionalData = json['additionalData'].cast<String, dynamic>();
246246

247247
if (json.containsKey('backgroundImageLayout')) {
248-
this.backgroundImageLayout = OSAndroidBackgroundImageLayout(json['backgroundImageLayout'] as Map<dynamic, dynamic>);
248+
this.backgroundImageLayout = OSAndroidBackgroundImageLayout(json['backgroundImageLayout'].cast<String, dynamic>());
249249
}
250250

251251
// raw payload comes as a JSON string
@@ -259,7 +259,7 @@ class OSNotificationPayload extends JSONStringRepresentable {
259259
this.buttons = List<OSActionButton>();
260260
var btns = json['buttons'] as List<dynamic>;
261261
for (var btn in btns) {
262-
var serialized = btn as Map<dynamic, dynamic>;
262+
var serialized = btn.cast<String, dynamic>();
263263
this.buttons.add(OSActionButton.fromJson(serialized));
264264
}
265265
}
@@ -279,11 +279,11 @@ class OSNotificationOpenedResult {
279279
OSNotificationAction action;
280280

281281
//constructor
282-
OSNotificationOpenedResult(Map<dynamic, dynamic> json) {
283-
this.notification = OSNotification(json['notification'] as Map<dynamic, dynamic>);
282+
OSNotificationOpenedResult(Map<String, dynamic> json) {
283+
this.notification = OSNotification(json['notification'].cast<String, dynamic>());
284284

285285
if (json.containsKey('action')) {
286-
this.action = OSNotificationAction(json['action'] as Map<dynamic, dynamic>);
286+
this.action = OSNotificationAction(json['action'].cast<String, dynamic>());
287287
}
288288
}
289289
}
@@ -305,7 +305,7 @@ class OSNotificationAction {
305305
/// that the user tapped
306306
String actionId;
307307

308-
OSNotificationAction(Map<dynamic, dynamic> json) {
308+
OSNotificationAction(Map<String, dynamic> json) {
309309
this.type = OSNotificationActionType.opened;
310310
this.actionId = json['id'] as String;
311311

@@ -330,7 +330,7 @@ class OSActionButton extends JSONStringRepresentable {
330330

331331
OSActionButton({@required this.id, @required this.text, this.icon});
332332

333-
OSActionButton.fromJson(Map<dynamic, dynamic> json) {
333+
OSActionButton.fromJson(Map<String, dynamic> json) {
334334
this.id = json['id'] as String;
335335
this.text = json['text'] as String;
336336

@@ -366,7 +366,7 @@ class OSAndroidBackgroundImageLayout extends JSONStringRepresentable {
366366
/// The color of the body text
367367
String bodyTextColor;
368368

369-
OSAndroidBackgroundImageLayout(Map<dynamic, dynamic> json) {
369+
OSAndroidBackgroundImageLayout(Map<String, dynamic> json) {
370370
if (json.containsKey('image')) this.image = json['image'] as String;
371371
if (json.containsKey('titleTextColor')) this.titleTextColor = json['titleTextColor'] as String;
372372
if (json.containsKey('bodyTextColor')) this.bodyTextColor = json['bodyTextColor'] as String;

lib/src/permission.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import 'package:OneSignalFlutter/src/subscription.dart';
2-
import 'package:OneSignalFlutter/src/defines.dart';
3-
import 'package:OneSignalFlutter/src/utils.dart';
1+
import 'package:onesignal/src/subscription.dart';
2+
import 'package:onesignal/src/defines.dart';
3+
import 'package:onesignal/src/utils.dart';
44

55
class OSPermissionState extends JSONStringRepresentable {
66
bool hasPrompted; // iOS only
77
bool provisional; //iOS only
88
OSNotificationPermission status;
99

10-
OSPermissionState(Map<dynamic, dynamic> json) {
10+
OSPermissionState(Map<String, dynamic> json) {
1111

1212
if (json.containsKey('status')) {
1313
//ios
@@ -44,10 +44,10 @@ class OSPermissionSubscriptionState extends JSONStringRepresentable {
4444
OSSubscriptionState subscriptionStatus;
4545
OSEmailSubscriptionState emailSubscriptionStatus;
4646

47-
OSPermissionSubscriptionState(Map<dynamic, dynamic> json) {
48-
this.permissionStatus = OSPermissionState(json['permissionStatus']);
49-
this.subscriptionStatus = OSSubscriptionState(json['subscriptionStatus']);
50-
this.emailSubscriptionStatus = OSEmailSubscriptionState(json['emailSubscriptionStatus']);
47+
OSPermissionSubscriptionState(Map<String, dynamic> json) {
48+
this.permissionStatus = OSPermissionState(json['permissionStatus'].cast<String, dynamic>());
49+
this.subscriptionStatus = OSSubscriptionState(json['subscriptionStatus'].cast<String, dynamic>());
50+
this.emailSubscriptionStatus = OSEmailSubscriptionState(json['emailSubscriptionStatus'].cast<String, dynamic>());
5151
}
5252

5353
String jsonRepresentation() {
@@ -63,7 +63,7 @@ class OSPermissionStateChanges extends JSONStringRepresentable {
6363
OSPermissionState from;
6464
OSPermissionState to;
6565

66-
OSPermissionStateChanges(Map<dynamic, dynamic> json) {
66+
OSPermissionStateChanges(Map<String, dynamic> json) {
6767
this.from = OSPermissionState(json['from']);
6868
this.to = OSPermissionState(json['to']);
6969
}

0 commit comments

Comments
 (0)