Commit d799b1bc authored by Libin Lu's avatar Libin Lu

update example for 4.0.0

parent 32c3ce4f
...@@ -5,7 +5,7 @@ buildscript { ...@@ -5,7 +5,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.0.0' classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.0.0' classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
......
#Fri Jan 06 16:34:59 EST 2017
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#import "AppDelegate.h" #import "AppDelegate.h"
#import "RCTBundleURLProvider.h" #import <React/RCTBundleURLProvider.h>
#import "RCTRootView.h" #import "RCTRootView.h"
#import "RNFIRMessaging.h" #import "RNFIRMessaging.h"
...@@ -35,34 +35,31 @@ ...@@ -35,34 +35,31 @@
[self.window makeKeyAndVisible]; [self.window makeKeyAndVisible];
[FIRApp configure]; [FIRApp configure];
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self]; [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
#endif
return YES; return YES;
} }
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler { {
[[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:notification.request.content.userInfo]; [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:notification.request.content.userInfo];
if([[notification.request.content.userInfo valueForKey:@"show_in_foreground"] isEqual:@YES]) { if([[notification.request.content.userInfo valueForKey:@"show_in_foreground"] isEqual:@YES]){
completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound); completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionSound);
} else { }else{
completionHandler(UNNotificationPresentationOptionNone); completionHandler(UNNotificationPresentationOptionNone);
} }
} }
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler { - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler
{
NSDictionary* userInfo = [[NSMutableDictionary alloc] initWithDictionary: response.notification.request.content.userInfo]; NSDictionary* userInfo = [[NSMutableDictionary alloc] initWithDictionary: response.notification.request.content.userInfo];
[userInfo setValue:@YES forKey:@"opened_from_tray"]; [userInfo setValue:@YES forKey:@"opened_from_tray"];
[[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:userInfo]; [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:userInfo];
} }
#else
//You can skip this method if you don't want to use local notification -(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:notification.userInfo];
[[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self + userInfo:notification.userInfo];
} }
#endif
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
[[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:userInfo]; [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:userInfo];
......
...@@ -30,17 +30,17 @@ ...@@ -30,17 +30,17 @@
/// <li>user_engagement</li> /// <li>user_engagement</li>
/// </ul> /// </ul>
/// ///
/// @param name The name of the event. Should contain 1 to 32 alphanumeric characters or /// @param name The name of the event. Should contain 1 to 40 alphanumeric characters or
/// underscores. The name must start with an alphabetic character. Some event names are /// underscores. The name must start with an alphabetic character. Some event names are
/// reserved. See FIREventNames.h for the list of reserved event names. The "firebase_" prefix /// reserved. See FIREventNames.h for the list of reserved event names. The "firebase_" prefix
/// is reserved and should not be used. Note that event names are case-sensitive and that /// is reserved and should not be used. Note that event names are case-sensitive and that
/// logging two events whose names differ only in case will result in two distinct events. /// logging two events whose names differ only in case will result in two distinct events.
/// @param parameters The dictionary of event parameters. Passing nil indicates that the event has /// @param parameters The dictionary of event parameters. Passing nil indicates that the event has
/// no parameters. Parameter names can be up to 24 characters long and must start with an /// no parameters. Parameter names can be up to 40 characters long and must start with an
/// alphabetic character and contain only alphanumeric characters and underscores. Only NSString /// alphabetic character and contain only alphanumeric characters and underscores. Only NSString
/// and NSNumber (signed 64-bit integer and 64-bit floating-point number) parameter types are /// and NSNumber (signed 64-bit integer and 64-bit floating-point number) parameter types are
/// supported. NSString parameter values can be up to 36 characters long. The "firebase_" prefix /// supported. NSString parameter values can be up to 100 characters long. The "firebase_"
/// is reserved and should not be used for parameter names. /// prefix is reserved and should not be used for parameter names.
+ (void)logEventWithName:(nonnull NSString *)name + (void)logEventWithName:(nonnull NSString *)name
parameters:(nullable NSDictionary<NSString *, NSObject *> *)parameters; parameters:(nullable NSDictionary<NSString *, NSObject *> *)parameters;
...@@ -68,4 +68,28 @@ ...@@ -68,4 +68,28 @@
/// non-empty and no more than 36 characters long. Setting userID to nil removes the user ID. /// non-empty and no more than 36 characters long. Setting userID to nil removes the user ID.
+ (void)setUserID:(nullable NSString *)userID; + (void)setUserID:(nullable NSString *)userID;
/// Sets the current screen name, which specifies the current visual context in your app. This helps
/// identify the areas in your app where users spend their time and how they interact with your app.
///
/// Note that screen reporting is enabled automatically and records the class name of the current
/// UIViewController for you without requiring you to call this method. If you implement
/// viewDidAppear in your UIViewController but do not call [super viewDidAppear:], that screen class
/// will not be automatically tracked. The class name can optionally be overridden by calling this
/// method in the viewDidAppear callback of your UIViewController and specifying the
/// screenClassOverride parameter.
///
/// If your app does not use a distinct UIViewController for each screen, you should call this
/// method and specify a distinct screenName each time a new screen is presented to the user.
///
/// The screen name and screen class remain in effect until the current UIViewController changes or
/// a new call to setScreenName:screenClass: is made.
///
/// @param screenName The name of the current screen. Should contain 1 to 100 characters. Set to nil
/// to clear the current screen name.
/// @param screenClassOverride The name of the screen class. Should contain 1 to 100 characters. By
/// default this is the class name of the current UIViewController. Set to nil to revert to the
/// default class name.
+ (void)setScreenName:(nullable NSString *)screenName
screenClass:(nullable NSString *)screenClassOverride;
@end @end
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
/// Params supply information that contextualize Events. You can associate up to 25 unique Params /// Params supply information that contextualize Events. You can associate up to 25 unique Params
/// with each Event type. Some Params are suggested below for certain common Events, but you are /// with each Event type. Some Params are suggested below for certain common Events, but you are
/// not limited to these. You may supply extra Params for suggested Events or custom Params for /// not limited to these. You may supply extra Params for suggested Events or custom Params for
/// Custom events. Param names can be up to 24 characters long, may only contain alphanumeric /// Custom events. Param names can be up to 40 characters long, may only contain alphanumeric
/// characters and underscores ("_"), and must start with an alphabetic character. Param values can /// characters and underscores ("_"), and must start with an alphabetic character. Param values can
/// be up to 36 characters long. The "firebase_" prefix is reserved and should not be used. /// be up to 100 characters long. The "firebase_" prefix is reserved and should not be used.
/// Game achievement ID (NSString). /// Game achievement ID (NSString).
/// <pre> /// <pre>
...@@ -283,8 +283,8 @@ static NSString *const kFIRParameterTravelClass = @"travel_class"; ...@@ -283,8 +283,8 @@ static NSString *const kFIRParameterTravelClass = @"travel_class";
/// a general purpose parameter that is useful for accumulating a key metric that pertains to an /// a general purpose parameter that is useful for accumulating a key metric that pertains to an
/// event. Examples include revenue, distance, time and points. Value should be specified as signed /// event. Examples include revenue, distance, time and points. Value should be specified as signed
/// 64-bit integer or double as NSNumber. Notes: Currency-related values should be supplied using /// 64-bit integer or double as NSNumber. Notes: Currency-related values should be supplied using
/// double as NSNumber and must be accompanied by a {@link kFIRParameterCurrency} parameter. The /// double as NSNumber and must be accompanied by a @c kFIRParameterCurrency parameter. The valid
/// valid range of accumulated values is [-9,223,372,036,854.77, 9,223,372,036,854.77]. /// range of accumulated values is [-9,223,372,036,854.77, 9,223,372,036,854.77].
/// <pre> /// <pre>
/// NSDictionary *params = @{ /// NSDictionary *params = @{
/// kFIRParameterValue : @(3.99), /// kFIRParameterValue : @(3.99),
......
...@@ -14,7 +14,6 @@ framework module FirebaseAnalytics { ...@@ -14,7 +14,6 @@ framework module FirebaseAnalytics {
header "FIRParameterNames.h" header "FIRParameterNames.h"
header "FIRUserPropertyNames.h" header "FIRUserPropertyNames.h"
link framework "AddressBook"
link framework "StoreKit" link framework "StoreKit"
link "c++" link "c++"
......
...@@ -5,13 +5,14 @@ ...@@ -5,13 +5,14 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/** A block that takes a BOOL and has no return value. */
typedef void (^FIRAppVoidBoolCallback)(BOOL success); typedef void (^FIRAppVoidBoolCallback)(BOOL success);
/** /**
* The entry point of Firebase SDKs. * The entry point of Firebase SDKs.
* *
* Initialize and configure FIRApp using [FIRApp configure]; * Initialize and configure FIRApp using +[FIRApp configure]
* Or other customized ways as shown below. * or other customized ways as shown below.
* *
* The logging system has two modes: default mode and debug mode. In default mode, only logs with * The logging system has two modes: default mode and debug mode. In default mode, only logs with
* log level Notice, Warning and Error will be sent to device. In debug mode, all logs will be sent * log level Notice, Warning and Error will be sent to device. In debug mode, all logs will be sent
...@@ -62,22 +63,22 @@ typedef void (^FIRAppVoidBoolCallback)(BOOL success); ...@@ -62,22 +63,22 @@ typedef void (^FIRAppVoidBoolCallback)(BOOL success);
+ (nullable FIRApp *)appNamed:(NSString *)name; + (nullable FIRApp *)appNamed:(NSString *)name;
/** /**
* Returns the set of all extant FIRApp instances, or nil if there is no FIRApp instance. This * Returns the set of all extant FIRApp instances, or nil if there are no FIRApp instances. This
* method is thread safe. * method is thread safe.
*/ */
+ (nullable NSDictionary *)allApps; + (nullable NSDictionary *)allApps;
/** /**
* Cleans up the current FIRApp, freeing associated data and returning its name to the pool for * Cleans up the current FIRApp, freeing associated data and returning its name to the pool for
* future use. This method is thread safe in class level. * future use. This method is thread safe.
*/ */
- (void)deleteApp:(FIRAppVoidBoolCallback)completion; - (void)deleteApp:(FIRAppVoidBoolCallback)completion;
/** /**
* FIRFirebaseApp instances should not be initialized directly. Call |FIRApp configure|, or * FIRApp instances should not be initialized directly. Call +[FIRApp configure],
* |FIRApp configureWithOptions:|, or |FIRApp configureWithNames:options| directly. * +[FIRApp configureWithOptions:], or +[FIRApp configureWithNames:options:] directly.
*/ */
- (nullable instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
/** /**
* Gets the name of this app. * Gets the name of this app.
......
...@@ -6,11 +6,17 @@ ...@@ -6,11 +6,17 @@
* The log levels used by FIRConfiguration. * The log levels used by FIRConfiguration.
*/ */
typedef NS_ENUM(NSInteger, FIRLogLevel) { typedef NS_ENUM(NSInteger, FIRLogLevel) {
/** Error */
kFIRLogLevelError __deprecated = 0, kFIRLogLevelError __deprecated = 0,
/** Warning */
kFIRLogLevelWarning __deprecated, kFIRLogLevelWarning __deprecated,
/** Info */
kFIRLogLevelInfo __deprecated, kFIRLogLevelInfo __deprecated,
/** Debug */
kFIRLogLevelDebug __deprecated, kFIRLogLevelDebug __deprecated,
/** Assert */
kFIRLogLevelAssert __deprecated, kFIRLogLevelAssert __deprecated,
/** Max */
kFIRLogLevelMax __deprecated = kFIRLogLevelAssert kFIRLogLevelMax __deprecated = kFIRLogLevelAssert
} DEPRECATED_MSG_ATTRIBUTE( } DEPRECATED_MSG_ATTRIBUTE(
"Use -FIRDebugEnabled and -FIRDebugDisabled. See FIRApp.h for more details."); "Use -FIRDebugEnabled and -FIRDebugDisabled. See FIRApp.h for more details.");
...@@ -21,12 +27,13 @@ typedef NS_ENUM(NSInteger, FIRLogLevel) { ...@@ -21,12 +27,13 @@ typedef NS_ENUM(NSInteger, FIRLogLevel) {
*/ */
@interface FIRConfiguration : NSObject @interface FIRConfiguration : NSObject
/** Returns the shared configuration object. */
+ (FIRConfiguration *)sharedInstance; + (FIRConfiguration *)sharedInstance;
// The configuration class for Firebase Analytics. /** The configuration class for Firebase Analytics. */
@property(nonatomic, readwrite) FIRAnalyticsConfiguration *analyticsConfiguration; @property(nonatomic, readwrite) FIRAnalyticsConfiguration *analyticsConfiguration;
// Global log level. Defaults to kFIRLogLevelError. /** Global log level. Defaults to kFIRLogLevelError. */
@property(nonatomic, readwrite, assign) FIRLogLevel logLevel DEPRECATED_MSG_ATTRIBUTE( @property(nonatomic, readwrite, assign) FIRLogLevel logLevel DEPRECATED_MSG_ATTRIBUTE(
"Use -FIRDebugEnabled and -FIRDebugDisabled. See FIRApp.h for more details."); "Use -FIRDebugEnabled and -FIRDebugDisabled. See FIRApp.h for more details.");
......
...@@ -43,31 +43,31 @@ FOUNDATION_EXPORT NSString * __nonnull const FIRMessagingMessagesDeletedNotifica ...@@ -43,31 +43,31 @@ FOUNDATION_EXPORT NSString * __nonnull const FIRMessagingMessagesDeletedNotifica
* @enum FIRMessagingError * @enum FIRMessagingError
*/ */
typedef NS_ENUM(NSUInteger, FIRMessagingError) { typedef NS_ENUM(NSUInteger, FIRMessagingError) {
// Unknown error. /// Unknown error.
FIRMessagingErrorUnknown = 0, FIRMessagingErrorUnknown = 0,
// Auth Error -- FIRMessaging couldn't validate request from this client. /// FIRMessaging couldn't validate request from this client.
FIRMessagingErrorAuthentication = 1, FIRMessagingErrorAuthentication = 1,
// NoAccess -- InstanceID service cannot be accessed. /// InstanceID service cannot be accessed.
FIRMessagingErrorNoAccess = 2, FIRMessagingErrorNoAccess = 2,
// Timeout -- Request to InstanceID backend timed out. /// Request to InstanceID backend timed out.
FIRMessagingErrorTimeout = 3, FIRMessagingErrorTimeout = 3,
// Network -- No network available to reach the servers. /// No network available to reach the servers.
FIRMessagingErrorNetwork = 4, FIRMessagingErrorNetwork = 4,
// OperationInProgress -- Another similar operation in progress, /// Another similar operation in progress, bailing this one.
// bailing this one.
FIRMessagingErrorOperationInProgress = 5, FIRMessagingErrorOperationInProgress = 5,
// InvalidRequest -- Some parameters of the request were invalid. /// Some parameters of the request were invalid.
FIRMessagingErrorInvalidRequest = 7, FIRMessagingErrorInvalidRequest = 7,
}; };
/// Status for the downstream message received by the app. /// Status for the downstream message received by the app.
typedef NS_ENUM(NSInteger, FIRMessagingMessageStatus) { typedef NS_ENUM(NSInteger, FIRMessagingMessageStatus) {
/// Unknown status.
FIRMessagingMessageStatusUnknown, FIRMessagingMessageStatusUnknown,
/// New downstream message received by the app. /// New downstream message received by the app.
FIRMessagingMessageStatusNew, FIRMessagingMessageStatusNew,
...@@ -76,6 +76,7 @@ typedef NS_ENUM(NSInteger, FIRMessagingMessageStatus) { ...@@ -76,6 +76,7 @@ typedef NS_ENUM(NSInteger, FIRMessagingMessageStatus) {
/// Information about a downstream message received by the app. /// Information about a downstream message received by the app.
@interface FIRMessagingMessageInfo : NSObject @interface FIRMessagingMessageInfo : NSObject
/// The status of the downstream message
@property(nonatomic, readonly, assign) FIRMessagingMessageStatus status; @property(nonatomic, readonly, assign) FIRMessagingMessageStatus status;
@end @end
...@@ -121,7 +122,7 @@ typedef NS_ENUM(NSInteger, FIRMessagingMessageStatus) { ...@@ -121,7 +122,7 @@ typedef NS_ENUM(NSInteger, FIRMessagingMessageStatus) {
* In order to receive FIRMessaging messages, declare application:didReceiveRemoteNotification: * In order to receive FIRMessaging messages, declare application:didReceiveRemoteNotification:
* *
* Client apps can send upstream messages back to the app server using the XMPP-based * Client apps can send upstream messages back to the app server using the XMPP-based
* <a href="http://developers.google.com/cloud-messaging/ccs.html">Cloud Connection Server</a>, * <a href="https://developers.google.com/cloud-messaging/ccs.html">Cloud Connection Server</a>
* *
*/ */
@interface FIRMessaging : NSObject @interface FIRMessaging : NSObject
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<key>RNFIRMessaging.xcscheme</key> <key>RNFIRMessaging.xcscheme</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>5</integer> <integer>7</integer>
</dict> </dict>
</dict> </dict>
<key>SuppressBuildableAutocreation</key> <key>SuppressBuildableAutocreation</key>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment