iOS遠端推送之友盟Push

2021-09-07 03:15:44 字數 2954 閱讀 3197

更新記錄:

1、2023年10月23日上午10:10分更新,優化了該類,去除了不必要的方法。

入職後的乙個任務,就是做遠端推送,聽老大說用的是友盟push.所以就看了一下友盟push,具體的整合以及證書的生成請參照這裡。具體的就不再多說了,主要是自己重新封裝了一下umessage,具體的內容如下:

//

//notepad

////

created by zhanggui on 15/10/19.

////

#import

#import

#import

"umessage.h

"@inte***ce

zgumessagepush : nsobject

+(instancetype)shared;/**

*裝置註冊友盟推送 */

+ (void)registerumessagewithoptions:(nsdictionary *)launchoptions;/**

*註冊裝置devicetoken */

+ (void)registerdevicewithtoken:(nsdata *)data; /*

* *程式未執行的時候,推送訊息的處理

* @param userinfo:推送過來的資料 */

/***程式執行的時候,推送訊息的處理

*@param userinfo:推送過來的資料 */

/** *預設的繫結使用者賬號 */

+ (void

)bandingdefaultcount;/**

*解綁使用者賬號 */

+ (void

)unbandingdefaultcount;/**

繫結賬號

@param account:要繫結的使用者名稱 */

+ (void)bandingthecount:(nsstring *)account;/**

*解綁使用者賬號 */

+ (void

)unbandingthecount; /*

* *新增標籤 */

+ (void)addtags:(nsarray *)tagarray;

@end

以上是.h檔案。

//

//notepad

////

created by zhanggui on 15/10/19.

////

#import

"zgumessagepush.h

"#import

#import

"loginviewcontroller.h

"#import

"lefttableviewcontroller.h

"#define _iphone80_ 80000

#define umsystem_version_greater_than_or_equal_to(v) ([[[uidevice currentdevice] systemversion] compare:v options:nsnumericsearch] != nsorderedascending)

@implementation

zgumessagepush

+(instancetype)shared );

return

sharedpush;}//

+ (void)registerumessagewithoptions:(nsdictionary *)launchoptions

else

#else

//register remotenotification types (ios 8.0以下)

[umessage registerforremotenotificationtypes:uiremotenotificationtypebadge

|uiremotenotificationtypesound

|uiremotenotificationtypealert];

#endif

#if debug[umessage setlogenabled:yes];

#endif}

+ (void)registerdevicewithtoken:(nsdata *)data

[umessage setautoalert:no];

uialertview *alert = [[uialertview alloc] initwithtitle:@"

程式未執行的邏輯處理

" message:[userinfo objectforkey:@"

name

"] delegate:nil cancelbuttontitle:@"確定"

otherbuttontitles: nil];

[alert show];

} [umessage setautoalert:no];

程式在前台時邏輯處理

uialertview *alert = [[uialertview alloc] initwithtitle:@"

程式在前台的邏輯處理

" message:[userinfo objectforkey:@"

name

"] delegate:nil cancelbuttontitle:@"確定"

otherbuttontitles: nil];

[alert show];

}else

}+ (void

)bandingdefaultcount

}];}+ (void

)unbandingthecount

}];}+ (void)addtags:(nsarray *)tagarray

else

}];}

}}@end

注意事項:

1、如果是開發環境的話,需要新增devicetoken到友盟推送後台。

thinkphp整合系列之友盟訊息推送

上篇文章 thinkphp整合系列之phpmailer批量傳送郵件講過的 郵件有著零成本 內容豐富的優點 但是乙個非常硬的硬傷 這傢伙的及時性太差了 唯一有的郵箱也還是自動開通的qq郵箱 然而還是一連串的未讀 那麼有木有一種零成本 但是及時性比較好的方案呢?今個先就友盟的推送來講解下 依然是以開源專...

iOS 遠端推送

ios應用的 之需做2件事情 1.在程式啟動時,註冊遠端通知服務,說白了 就是發訊息給蘋果,詢問 我的最新devicetoken是多少?注意 第一次註冊時,需要使用者授權,也就是我們常見的 應用 想要給您傳送推送通知 具體的 如下 註冊遠端通知服務 uiremotenotificationtypes...

IOS整合友盟推送UMengPush

按以下步驟絕對好使 1.證書配置 2.裝置描述顯示紅色,篩選結果為空 b.刪除應用重新執行 c.友盟後台有延遲,幾分鐘不等 d.顯示黑色可以測試資訊 配置 如果還是不行ios首先用以下 判斷有木有錯誤 didfailtoregisterforremotenotificationswitherror ...