Skip to content
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

change library & RCTPushbots.h & RCTPushbots.m #11

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
44 changes: 25 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,30 +75,36 @@ in your App.js:


```javascript
import {
Alert
} from 'react-native';

import { Text} from 'react-native';
import React, { Component } from 'react';
import Pushbots from 'pushbots-react-native'

Pushbots.registerForRemoteNotifications()

export default class App extends Component<{}> {
componentWillMount() {
Pushbots.addEventListener('received', this.onReceived);
Pushbots.addEventListener('opened', this.onOpened);
}
componentWillUnmount() {
Pushbots.removeEventListener('received', this.onReceived);
Pushbots.removeEventListener('opened', this.onOpened); }
onReceived(notification) {
Alert.alert( 'Received Notification', JSON.stringify(notification), [ {text: 'Ask me later', onPress: () => console.log('Ask me later pressed')}, {text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel'}, {text: 'OK', onPress: () => console.log('OK Pressed')}, ], { cancelable: false } )
}
onOpened(notification) {
Alert.alert( 'Opened Notification', JSON.stringify(notification), [ {text: 'Ask me later', onPress: () => console.log('Ask me later pressed')}, {text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel'}, {text: 'OK', onPress: () => console.log('OK Pressed')}, ], { cancelable: false } )
}
Pushbots.registerForRemoteNotifications()
export default class App extends Component {
constructor(properties) {
super(properties);
Pushbots.addEventListener('received', this.onReceived);
Pushbots.addEventListener('opened', this.onOpened);
}
componentWillUnmount() {
Pushbots.removeEventListener('received', this.onReceived);
Pushbots.removeEventListener('opened', this.onOpened); }

onReceived(notification) {
console.log('Received Notification: ', notification);
}
onOpened(notification) {
console.log('Opened Notification: ', notification);
}
render() {
return (
<Text>Hello From Pushbots</Text>
);
}
}


```

## Contributors
Expand Down
Binary file modified android/src/.DS_Store
Binary file not shown.
Binary file modified android/src/main/.DS_Store
Binary file not shown.
Binary file modified android/src/main/java/.DS_Store
Binary file not shown.
Binary file modified android/src/main/java/com/.DS_Store
Binary file not shown.
Binary file modified android/src/main/java/com/pushbots/.DS_Store
Binary file not shown.
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import { NativeModules, NativeAppEventEmitter, Platform } from 'react-native';
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';

const RNPushbotsModule = NativeModules.Pushbots;

const not_handlers = new Map();
const eventEmitter = new NativeEventEmitter(RNPushbotsModule);


export default class Pushbots {
static addEventListener(type: any, handler: Function) {
var listener;
if (type === 'received') {
listener = NativeAppEventEmitter.addListener(
listener = eventEmitter.addListener(
'Pushbots__RemoteNotificationReceived',
(notification) => {
handler(notification);
}
);
}else if (type === 'opened') {
listener = NativeAppEventEmitter.addListener(
listener = eventEmitter.addListener(
'Pushbots__RemoteNotificationOpened',
(notification) => {
handler(notification);
Expand Down Expand Up @@ -126,4 +127,4 @@ export default class Pushbots {
RNPushbotsModule.clearBadgeCount()
}
}
}
}
Binary file modified ios/.DS_Store
Binary file not shown.
Binary file added ios/Pushbots.framework/CloseButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Pushbots.framework/CloseButton@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ios/Pushbots.framework/CloseButton@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 23 additions & 3 deletions ios/Pushbots.h → ios/Pushbots.framework/Headers/Pushbots.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/*!
@class
PushBots SDK v2.1.2
PushBots SDK v2.4.6
@abstract
The primary interface for integrating PushBots with your app.

Expand Down Expand Up @@ -43,6 +43,11 @@ typedef NS_ENUM(NSUInteger, PBLogLevel) {

typedef void (^PushBotsReceivedNotification)(NSDictionary * result);
typedef void (^PushBotsOpenedNotification)(NSDictionary * result);
typedef void (^PushBotsRegistered)(NSString * userid);

+ (void) onRegistered:(PushBotsRegistered)rCallback;


/*!
@method

Expand Down Expand Up @@ -103,7 +108,7 @@ typedef void (^PushBotsOpenedNotification)(NSDictionary * result);

*/
+ (void)setLogLevel:(PBLogLevel)pbloglevel;

+ (void)setLogLevel:(PBLogLevel)pbloglevel isUILog:(BOOL)uiLog;
/*!
@method

Expand Down Expand Up @@ -138,6 +143,8 @@ Show prompt to register with remote notifications.
@param callback callback block to get device data as NSDictionary
*/
+ (void) getDevice:(void (^)(NSDictionary *device, NSError *error))callback;
+ (void) checkInApp:(void (^)(NSArray *inappmessages, NSError *error))callback;
+(void) inAppNotificationOpenedWithId:(NSString *) inapp_id;

/*!
@method
Expand Down Expand Up @@ -183,6 +190,14 @@ This method will toggle debug mode on the device, visit sandbox section in dashb
*/
+ (void) setAlias:(NSString *)alias;

+ (void) setName:(NSString *)name;
+ (void) setFirstName:(NSString *)f_name;
+ (void) setLastName:(NSString *)l_name;
+ (void) setEmail:(NSString *)email;
+ (void) setGender:(NSString *)gender;
+ (void) setPhone:(NSString *)phone;



/*!
@method
Expand Down Expand Up @@ -264,21 +279,26 @@ This method will toggle debug mode on the device, visit sandbox section in dashb

*/
+ (void) toggleNotifications:(BOOL)subscribed;
+ (BOOL)showTakeoverNotificationWithObject:(NSDictionary *) notification;
+ (void)showTakeoverNotificationWith:(NSDictionary *) notification;
+ (BOOL) validateInAppMessage:(NSDictionary *) message;

+ (void) trackPushNotificationOpenedWithLaunchOptions:(NSDictionary *) launchOptions;
+ (void) trackPushNotificationOpenedWithPayload:(NSDictionary *) payload;
+ (void) trackPushNotificationOpenedWithPoll:(NSDictionary *) payload andAnswerId:(NSString *)ansewerID sync:(BOOL) sync;

+(void) trackEvent:(NSString *)event;
+(void) trackEvent:(NSString *)event withValue:(NSString *)value;

+(void) shareLocation:(BOOL)isSharingEnabled;
+(void) shareLocationPrompt:(BOOL)isPrompt;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability"
#ifdef IOS10PLUS
// iOS 10 only
// Notification Service Extension
+ (UNMutableNotificationContent*)didReceiveNotificationExtensionRequest:(UNNotificationRequest*)request withContent:(UNMutableNotificationContent*)replacementContent;
+ (UNMutableNotificationContent*)serviceExtensionTimeWillExpireRequest:(UNNotificationRequest*)request withContent:(UNMutableNotificationContent*)replacementContent;

#endif
#pragma clang diagnostic pop

Expand Down
Binary file added ios/Pushbots.framework/Info.plist
Binary file not shown.
6 changes: 6 additions & 0 deletions ios/Pushbots.framework/Modules/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
framework module Pushbots {
umbrella header "Pushbots.h"

export *
module * { export * }
}
Binary file added ios/Pushbots.framework/Pushbots
Binary file not shown.
Loading